The NSString method initWithFormat:arguments: takes a va_list as an argument. I can't figure out when it would be used (or even how to use it). Why would Apple add such a method when the regular initWithFormat: is much more user-friendly?
You can't pass a dynamic list of format arguments to -initWithFormat:
. For example, if you wanted to implement -stringByAppendingFormat:
yourself without -initWithFormat:arguments:
, you'd have a job of it. With the va_list
version, you could do it:
- (NSString *)stringByAppendingFormat:(NSString *)format, ... {
va_list args;
va_start(args, format);
NSString * result = [self stringByAppendingString:[NSString stringWithFormat:format arguments:args]];
va_end(args);
return result;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With