我想NSTask(NSTask,launchpath和參數)傳遞給函數,但肯定我需要一些幫助與語義:聲明與多個參數的Objective-C的方法
AppleDelegate.h文件:
- (void)doTask:(NSTask*)theTask :(NSArray*)arguments :(NSString*)launchPath;
AppleDelegate.m文件:
- (void)doTask:(NSTask*)theTask :(NSArray*)arguments :(NSString*)launchPath
{
self.currentTask = theTask;
// do currentTask alloc, set the launcpath and the args, pipe and more
}
下面是代碼調用 「doTask」:
NSTask* runMyTask;
NSString *command = @"/usr/bin/hdiutil";
NSArray* taskArgs = [NSArray arrayWithObjects:@"info", @"/", nil];
// Here the error:
[self doTask:runMyTask, taskArgs, command]; // ARC Semantic issue no visible interface for AppleDelegate declares the selector 'doTask'..
選擇器顯示爲未聲明,但我認爲我確實聲明瞭它... 是否有可能做這樣的事情,錯誤在哪裏?
[Objective C中的方法語法]的可能的重複(http://stackoverflow.com/questions/683211/method-syntax-in-objective-c) – Caleb