Multiple unknown parameters in IOS

Source: Internet
Author: User

Multiple unknown parameters in IOS

-(Void) setGradientColor :( UIColor *) beginColor transitionColor :( UIColor *) transitionColor,... NS_REQUIRES_NIL_TERMINATION;

 

// NS_REQUIRES_NIL_TERMINATION, used for non-nil end check during compilation

-(Void) setGradientColor :( UIColor *) beginColor transitionColor :( UIColor *) transitionColor ,...{

[Self. gradientColors addObject :( id) beginColor. CGColor];

// Define a pointer to the list of optional parameters

Va_list args;

 

// Obtain the address of the first optional parameter. The parameter list Pointer Points to the first optional parameter in the function parameter list.

Va_start (args, transitionColor );

 

If (transitionColor)

{

[Self. gradientColors addObject :( id) transitionColor. CGColor];

 

// Traverse the parameters in the parameter list and point the parameter list pointer to the next parameter in the parameter list

UIColor * nextArg;

While (nextArg = va_arg (args, UIColor *)))

{

[Self. gradientColors addObject :( id) nextArg. CGColor];

}

}

// End variable parameter acquisition (clear the parameter list)

Va_end (args );

}

 

[DrawCircleView setGradientColor: [UIColor purpleColor] transitionColor: [UIColor redColor], [UIColor blueColor], nil];

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.