Cocoa only supports two built-in parameters. What should we do if there are more than two parameters? The following code shows how to implement a method to call more than seven parameters (from three20)
Upload upload-(ID) Upload mselector :( SEL) selector withobject :( ID) P1 withobject :( ID) P2 withobject :( ID) P3 then withobject :( ID) P4 withobject :( ID) p5 withobject :( ID) P6 withobject :( ID) P7
{Signature {
Nsmethodsignature * Sig = [self methodsignatureforselector: Selector]; Role
If (SIG)
{Export nsinvocation * invo = [nsinvocation invocationwithmethodsignature: SIG]; then
[Invo settarget: Self]; Reset
[Invo setselector: Selector]; then
[Invo setargument: & P1 atindex: 2]; then
[Invo setargument: & p2 atindex: 3]; then
[Invo setargument: & P3 atindex: 4]; then
[Invo setargument: & P4 atindex: 5]; then
[Invo setargument: & P5 atindex: 6]; then
[Invo setargument: & P6 atindex: 7]; then
[Invo setargument: & P7 atindex: 8]; then
[Invo invoke]; then
If (SIG. methodreturnlength) {Parameters ){
Id anobject; Response;
[Invo getreturnvalue: & anobject]; returns
Return anobject; Response ;}
Else {Response Return nil; Response} response ;}}
Else {Response Return nil; Response} response ;}}