2

I would like to pass NSTask (NSTask, launchpath, and the args) to a function, but sure I need some help with the semantic:

AppleDelegate.h file:

- (void)doTask:(NSTask*)theTask :(NSArray*)arguments :(NSString*)launchPath;

AppleDelegate.m file:

- (void)doTask:(NSTask*)theTask :(NSArray*)arguments :(NSString*)launchPath
{
    self.currentTask = theTask;

    // do currentTask alloc, set the launcpath and the args, pipe and more
}

Here is the code to call "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'..

The selector appears as undeclared, but I thought I did declare it... Is it possible to do something like this, where is the mistake?

1

1 Answer 1

7

You should first do a tutorial like this one to understand the basics of Objective-C: http://tryobjectivec.codeschool.com/

About your question. Your method was called doTask:::. You could invoke it like this: [self doTask:runMyTask :taskArgs :command];. However, that is bad practice. You want every parameter reflected in your method name. Also, you don't want your method names to start with do or does.

So, rename your method:

- (void)runTask:(NSTask *)theTask arguments:(NSArray *)arguments launchPath:(NSString *)launchPath;

And call it like this:

[self runTask:runMyTask arguments:taskArgs launchPath:command];

Done.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.