2

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.

stream
  • 369
  • 1
  • 7
  • 18

1 Answers1

7
-(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];

}
Parag Bafna
  • 22,812
  • 8
  • 71
  • 144
  • 1
    @stream: Amazing you accepted but din't upvoted!!! Always upvote if you like an answer. this boosts the person who gives time for answer. And by reading you learn something. :) – Anoop Vaidya Feb 28 '13 at 06:55