A typical call to performSelectorOnMainThread: looks like this:
[target performSelectorOnMainThread:action withObject:foo waitUntilDone:NO];
where “result” is an argument passed to “action”. A corresponding action would be:
- (void)doSomethingWithThing1:(id *)thing1
What is the correct syntax for calling an action that takes > 1 argument? Such as:
- (void)doSomethingWithThing1:(id *)thing1 andThing2(id *)thing2 andAlsoThing3(id *)thing3
[target performSelectorOnMainThread:action withObject:??? waitUntilDone:NO];
In response to a similar question on passing non-objects to a method in
performSelectorOnMainThread:, I pointed out Dave Dribin’s category on NSObject, which lets you do something like the following:for performing your multi-argument method on the main thread. I think this is a pretty elegant solution. Behind the scenes, he wraps things in an NSInvocation, invoking that on the main thread.
The Amber framework does something similar to this, as well.