Is there any easy way to convert an Objective-C holding class of NSStrings into parameters for a function accepting a variable list of char *? Specifically I have a function like:
-(void)someFunction:(NSSomething *) var
that I want to forward to a C function like
void someCFunction(char * var, …)
Is there an easy way to go about this?
No, you can only do what you want if the number of arguments you’re passing is known at compile time. If you just want to convert a single string, use the
-UTF8Stringmessage:But if the number of strings will vary at runtime, you’ll need to use a different API, if one is available. For example, if there’s an API that took an array of strings, you could convert the Objective-C array into a C array: