A typical call to performSelectorOnMainThread:
looks like this:
[target performSelectorOnMainThread:action withObject:foo waitUntilDone:NO];
If you wish to preserve the method signature of the receiver then I think you'll need to look at using NSInvocation
which allows you to specify multiple argument values.
You could wrap your call and use a dictionary as a container for your arguments as suggested in another answer but to me this seems like a bit of a code smell.
A better solution along this line would be to create a class that encapsulates the argument values - i.e. a strongly typed approach. So for example instead of passing firstname
, surname
, you'd pass an instance of a Person
class. This is probably a better route to go down because methods with fewer arguments can yield cleaner code - but that's a whole other story.