Using va_list to build a formatted string
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