• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Using va_list to build a formatted string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using va_list to build a formatted string


  • Subject: Using va_list to build a formatted string
  • From: Graham Cox <email@hidden>
  • Date: Thu, 30 Jun 2016 12:38:32 +1000

Hi all,

Got a problem with variadic arguments.

I have a function thus:

void	XVLogEvent( NSString* format, ... )
{
	NSString* logString;

	va_list argsP;
	va_start( argsP, format );

	logString = [NSString stringWithFormat:format, argsP];

	va_end(argsP);

	XVEventLog* logger = [XVEventLog sharedEventLog];
	[logger appendLog:logString];
}


This function is invoked by a macro so I can easily deploy a special type of logging. The problem I have is with the line:

	logString = [NSString stringWithFormat:format, argsP];

which causes an EXC_BAD_ACCESS. Obviously I’m doing it wrong, but if I use NSLogv here, it works fine. How do I turn my variadic parameters into a fully formatted string?

—Graham



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Using va_list to build a formatted string
      • From: Wim Lewis <email@hidden>
  • Prev by Date: Re: Using va_list to build a formatted string
  • Next by Date: Re: Using va_list to build a formatted string
  • Previous by thread: Layout guide-based constraints and hiding the status bar
  • Next by thread: Re: Using va_list to build a formatted string
  • Index(es):
    • Date
    • Thread