对 performSelectorOnMainThread:
的典型调用如下所示:
[target performSelectorOnMainThread:action withObject:foo waitUntilDone:NO];
其中“结果”是传递给“操作”的参数。相应的操作是:
- (void)doSomethingWithThing1:(id *)thing1
调用采用 > 1 个参数的操作的正确语法是什么?如:
- (void)doSomethingWithThing1:(id *)thing1 andThing2(id *)thing2 andAlsoThing3(id *)thing3
[target performSelectorOnMainThread:action withObject:??? waitUntilDone:NO];
最佳答案
您可以通过将参数放入字典或数组并将其传递给特殊函数来做到这一点
- (void)doStuff:(NSString *)arg1 and:(NSString *)arg2 and:(NSString *)arg3 {
...
}
- (void)doStuff:(NSArray *)argArray {
[self doStuff:[argArray objectAtIndex:0]
and:[argArray objectAtIndex:1]
and:[argArray objectAtIndex:2];
}
关于iphone - 如何调用performSelectorOnMainThread : with an selector that takes > 1 arguments?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1460589/