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.
Asked
Active
Viewed 674 times
2

stream
- 369
- 1
- 7
- 18
-
Do you want to pass variable number of arguments? – Parag Bafna Feb 28 '13 at 06:17
-
Yes. I want to customize a method like [NSString stringWithFormat:<#(NSString *), ...#>]; – stream Feb 28 '13 at 06:20
1 Answers
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