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 4061670
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:29:56+00:00 2026-05-20T15:29:56+00:00

Hee Does anybody know how to implement an method in objective c that will

  • 0

Hee

Does anybody know how to implement an method in objective c that will take an array of arguments as parameter such as:

[NSArray arrayWithObjects:@"A",@"B",nil];

The method declaration for this method is:

+ (id)arrayWithObjects:(id)firstObj...

I can’t seem to make such method on my own. I did the following:

+ (void) doSometing:(id)string manyTimes:(NSInteger)numberOfTimes;

[SomeClass doSometing:@"A",@"B",nil manyTimes:2];

It will give the warningtoo many arguments to function ‘doSometing:manyTimes:’

Thanks already.

  • 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-05-20T15:29:57+00:00Added an answer on May 20, 2026 at 3:29 pm

    The ellipsis (…) is inherited from C; you can use it only as the final argument in a call (and you’ve missed out the relevant comma in your example). So in your case you’d probably want:

    + (void)doSomethingToObjects:(id)firstObject, ...;
    

    or, if you want the count to be explicit and can think of a way of phrasing it well:

    + (void)doManyTimes:(NSInteger)numberOfTimes somethingToObjects:(id)firstObject, ...;
    

    You can then use the normal C methods for dealing with ellipses, which reside in stdarg.h. There’s a quick documentation of those here, example usage would be:

    + (void)doSomethingToObjects:(id)firstObject, ...
    {
        id object;
        va_list argumentList;
    
        va_start(argumentList, firstObject);
        object = firstObject;
    
        while(1)
        {
            if(!object) break; // we're using 'nil' as a list terminator
    
            [self doSomethingToObject:object];
            object = va_arg(argumentList, id);
        }
    
        va_end(argumentList);
    }
    

    EDIT: additions, in response to comments. You can’t pass the various things handed to you in an ellipsis to another function that takes an ellipsis due to the way that C handles function calling (which is inherited by Objective-C, albeit not obviously so). Instead you tend to pass the va_list. E.g.

    + (NSString *)doThis:(SEL)selector makeStringOfThat:(NSString *)format, ...
    {
        // do this
        [self performSelector:selector];
    
        // make string of that...
    
        // get the argument list
        va_list argumentList;
        va_start(argumentList, format);
    
        // pass it verbatim to a suitable method provided by NSString
        NSString *string = [[NSString alloc] initWithFormat:format arguments:argumentList];
    
        // clean up
        va_end(argumentList);
    
        // and return, as per the synthetic example
        return [string autorelease];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hee Does anybody know how to check in-application if a mail account is setup
Hee Does anybody know how to recognize a multitask-kill. When the user puts the
Does google maps api use an older verison of their maps? When I embed
Really a buggy question , hee is the code: import java.io.IOException; import java.security.*; import
Hee, I'm kinda new to Qt and i started to add UnitTests to my
Update : This works in firefox, but does not work on chrome 6, still
I'm following the Rails Tutorial to get started (for the 4000th time) with Ruby
What is the best way to access the members of an rdf list? I'm
Any algorithm which changes a word from a string to a blank? I'm having
(I still feel like a complete newbie in MS Visual environments... so please bear

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.