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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:22:41+00:00 2026-05-27T03:22:41+00:00

I need to create in an iOS application a fake va_list to pass to

  • 0

I need to create in an iOS application a fake va_list to pass to a NSString initWithFormat:arguments: function, this is my code:

NSArray *fixedArguments = [[NSArray alloc] initWithArray:arguments]; 

NSRange range = NSMakeRange(0, [fixedArguments count]);

va_list fakeArgList = (va_list)malloc(sizeof(NSString *) * [fixedArguments count]);

__unsafe_unretained id *ptr = (__unsafe_unretained id *)fakeArgList;

[fixedArguments getObjects:ptr range:range];

content = [[NSString alloc] initWithFormat:outputFormat
                                            arguments:(va_list)fakeArgList];
free(fakeArgList);

The compiler complains with this message on the cast line:

error: cast of a non-Objective-C pointer type 'va_list' (aka 'char *') to '__unsafe_unretained id *' is disallowed with ARC

The getObjects:range: function is defined as follows:

- (void)getObjects:(id __unsafe_unretained [])objects range:(NSRange)range;

I’ve tried everything but still can’t get rid of this error…

Is there a solution for creating a fake va_list with ARC enabled? What am i doing wrong?

  • 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-27T03:22:42+00:00Added an answer on May 27, 2026 at 3:22 am

    EDIT: This no longer works. As foreseen in the initial answer, the ABI appears to have changed out from under this answer

    Played around for a bit and got it to work — Double checked for leaks or abandoned memory and didn’t see any.

        NSArray *fixedArguments = [[NSArray alloc] initWithObjects: @"foo", @"bar", @"baz", nil]; 
    
        NSRange range = NSMakeRange(0, [fixedArguments count]);
    
        NSMutableData* data = [NSMutableData dataWithLength: sizeof(id) * [fixedArguments count]];    
    
        [fixedArguments getObjects: (__unsafe_unretained id *)data.mutableBytes range:range];
    
        NSString* content = [[NSString alloc] initWithFormat: @"1: %@ 2: %@ 3: %@"  arguments: data.mutableBytes];
    
        NSLog(@"%@", content);
    

    I like to (ab)use NSMutableData like this to get retain/release semantics on an arbitrary chunk of memory — It’s not necessarily relevant to the issue at hand, but it’s a neat little trick.

    As a note to future readers: Faking up a va_list like this happens to work with the current ABI for MacOS and iOS, but in general it’s not portable, and not a good approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create an application capable to modify and manage files on IOS.
I need to create an iOS 5 application will run on iPad2 ( I
I need to create a server based (php) application with iOS client with authintication
I need to create a phonegap plugin for ios which fetches all artists from
I have a one-time need to create a file from an iOS mutable array.
I'm developing a library to IOS, which at some point need to create a
I need to create application shortcuts on 3 different mobile environments, WP7, Android and
I am attempting to create a simple iOS application, mostly for the learning process,
I am working on an iOS application and i need your help guys !
I need to create a common entity layer for my mobile phone application developments.(especially

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.