by koenigdavidmj · 13y ago · 0 comments
+ (id)stringWithFormat:(NSString *)format, ...;
This of course already exists, but if you wanted to do a Rubyfied version of it, then just follow the same general pattern.The reality is, that NSString needs native formatting sugar. Anything else would really just be a hack. I'm not particularly even happy with the [@"Hello ":@"World] syntax, either.
NSString *newS = @"blah " + @(42) + @"!"; newstr = [@"%d %@" format 42, @"blah"];
Implement it as a method that takes a dummy parameter, plus a macro: - (NSString *)format:(int)dummy, ...
#define format format:0,
Awful way to do it, but the resulting syntax is not entirely terrible.