我创建了一个NSInvocationOpertion对象,如下所示

NSString *myString = @"Jai Hanuman";
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(taskMethod) object:myString];
NSOperationQueue *operatioQueue = [[NSOperationQueue alloc] init];
    [operatioQueue addOperation:operation];


有人可以告诉我如何在taskMethod中访问myString对象吗?可能吗?

- (void)taskMethod{
    NSLog(@"Oh! Invocation's working buck");
}

最佳答案

您可以尝试以下方法:

将您的方法更改为:

- (void)taskMethod:(NSString *) message{
NSLog(@"Oh! Invocation's working buck");
        message=//your string object;
  }




NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(taskMethod:) object:myString];

10-08 06:04