我创建了一个 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];
关于ios - 如何在 NSInvocationOpreation 中传递对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29730304/