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

  • Home
  • SEARCH
  • 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 4075418
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:17:45+00:00 2026-05-20T17:17:45+00:00

Following the sample in article http://cocoawithlove.com/2009/05/variable-argument-lists-in-cocoa.html , I’ve written some custom handling of variable

  • 0

Following the sample in article http://cocoawithlove.com/2009/05/variable-argument-lists-in-cocoa.html, I’ve written some custom handling of variable argument methods for forwarding them to another method.

- (void) someMethod:(NSString *)name
   wittParamsAndKeys:(id)firstParam, ... {

va_list args;
va_start(args, firstParam);
NSDictionary* paramsAndKeys = 
    [[NSDictionary alloc] initWithObjectsAndKeys:firstParam, args, nil];
va_end(args);

}

But I get EXC_BAD_ACCESS. So then I tried removing nil from arguments to NSDictionary:

NSDictionary* paramsAndKeys = 
    [[NSDictionary alloc] initWithObjectsAndKeys:firstParam, args];

Again the exception. Now I’ve got an exception from initWithObjectsAndKeys: for invalid parameters.

I’m wondering if some way exists for just forwarding variable arguments to another method?

  • 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-20T17:17:45+00:00Added an answer on May 20, 2026 at 5:17 pm

    See this question: Variadic list parameter

    Generally it is not possible to do that. You have to parse all params and add them to that dictionary:

            NSMutableArray* values = [NSMutableArray arrayWithObject: first_param];
            NSMutableArray* keys = [NSMutableArray array];
            va_list args;
            va_start(args, t1);
            id arg;
            int i = 0;
            while ( ( arg = va_arg( args, id) ) != nil ) {
                if( (++i)%2 )
                    [values addObject: arg];
                else
                   [keys addObject: arg];
            }
    
    NSDictionary* dict = [NSDictionary dictionaryWithObjects: values forKeys: keys];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at Haacks article here - http://haacked.com/archive/2009/07/31/single-project-areas.aspx When I download the sample I
im just getting started on maven, and im currently following the article from http://www.sonatype.com/books/mvnex-book/reference/simple-project-sect-create-simple.html
I read the following article yesterday ( http://blogs.sitepoint.com/2010/11/19/mysql-mistakes-php-developers/ ) and it wrote the following:
http://lakers.sonikastudios.com/gallery/sample-gallery-post-1/ That post has several pages using the quicktag of Wordpress. This post is
I've written an implementation of Bresenham's algorithm in Python (following the Wikipedia article ),
In Microsoft's view injection sample/article they have the code like the following: public void
I have the following sample XML structure: <SavingAccounts> <SavingAccount> <ServiceOnline>yes</ServiceOnline> <ServiceViaPhone>no</ServiceViaPhone> </SavingAccount> <SavingAccount> <ServiceOnline>no</ServiceOnline>
I expected the two span tags in the following sample to display next to
I'm following the sample code in CFNetwork Programming Guide , specifically the section on
I have the following situation I think would be best to show in sample

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.