How does IOS use perform selector to call more than two parameters?

Source: Internet
Author: User

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 ;}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.