Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8094595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:50:33+00:00 2026-06-05T20:50:33+00:00

I have read in the Apple Documentation that we can use optional parameters in

  • 0

I have read in the Apple Documentation that we can use optional parameters in objective c methods call. Example from the Apple documentation :

Methods that take a variable number of parameters are also possible,
though they’re somewhat rare. Extra parameters are separated by commas
after the end of the method name. (Unlike colons, the commas are not
considered part of the name.) In the following example, the imaginary
makeGroup: method is passed one required parameter (group) and three
parameters that are optional:

[receiver makeGroup:group, memberOne, memberTwo, memberThree];

Can someone tell when to use this feature and how ? is there any example in the Apple API ?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:50:35+00:00Added an answer on June 5, 2026 at 8:50 pm

    The type of method you are describing is called a variadic method. Examples in Cocoa include +[NSArray arrayWithObjects:] and +[NSDictionary dictionaryWithObjectsAndKeys:]. You access the arguments of a variadic method (or function) using the macros defined in stdarg.h.

    Here’s an example of how the +[NSArray arrayWithObjects:] method might be implemented:

    + (NSArray *)arrayWithObjects:(id)firstObject, ... {
        int count = 0;
        va_list ap;
        va_start(ap, firstObject);
        id object = firstObject;
        while (object) {
            ++count;
            object = va_arg(ap, id);
        }
        va_end(ap);
    
        id objects[count];
        va_start(ap, firstObject);
        object = firstObject;
        for (int i = 0; i < count; ++i) {
            objects[i] = object;
            object = va_arg(ap, id);
        }
        va_end(ap);
    
        return [self arrayWithObjects:objects count:count];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read from some article that say's Apple doesn't approve the application which
I have read the Apple documentation regarding Mobile Device Management (MDM) but did not
I have read about NSPasteBoard in the Apple documentation, and how it allows for
I am building application that required some data from iPhone's Call log(read only). The
I read somewhere in apple documentation that I need to edit the plist to
I have read Apple's documentation and as many posts as I could here on
From the Apple Objective-C documentation, bolded relevant parts: Method Return and Parameter Types The
I have been faced with a claim that Apple has disallowed the use of
i've tried to read the apple documentation but i'll never use regular expression and
I have read the Apple documentation, and many postings on the subject on SO,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.