I want to invoke a selector of a method that has the usual nserror ** argument:
-( Int ) Getitemssince :( Nsdate *) When Dataselector :( Sel ) Getdataselector Error :( Nserror **) Outerror {
Nsarray * Data = Nil ;
If ([ Service respondstoselector : Getdataselector ]) {
Data = [ Service performselector : Getdataselector withobject : When Withobject : Outerror ];
// Etc.
... Which the compiler doesn't like:
Warning:Passing argument3Of'Your mselector: withobject :' FromIncompatible pointer type
¥ ¥ ¥
Check out nsinvocation, which gives you a more flexible way to "performselector ".
If ([ Service respondstoselector : Getdataselector ]) {
Nsarray * Data ;
Nsinvocation * Invocation = [ Nsinvocation Invocationwithmethodsignature :
[ Service methodsignatureforselector : Getdataselector ];
[ Invocation settarget : Delegate ];
[ Invocation setselector : Getdataselector ];
// Note: indexes 0 and 1 correspond to the implicit arguments self and _ cmd,
// Which are set using settarget and setselector.
[ Invocation setargument : When Atindex : 2 ];
[ Invocation setargument : Outerror atindex : 3 ];
[ Invocation invoke ];
[ Invocation getreturnvalue :& Data ];
}
//////////////////////////////////////// ////
Perform selector calls more than two parameters
You can also put all the parameters in the dictionary, such as nsnotification or nstimer userinfo.