Question

I want to customize a method with formated string input and (const char *) return,but the problem is like below... Can anyone tell me how to resolve it? Thanks. I want to customize a method with formated string input and (const char *) return,but the problem is like below... Can anyone tell me how to resolve it? Thanks.

Was it helpful?

Solution

-(const char *)stringWithFormat:(NSString *)format, ...
{
    va_list args;
    va_start(args, format);
    NSString *lString = [[NSString alloc] initWithFormat:format arguments:args];
    [lString autorelease];
    va_end(args);
    return [lString cStringUsingEncoding:NSUTF8StringEncoding];

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top