iOS: Concat NSString

- (NSString*)concatenateStrings:(NSString*)string, ...
{
NSString* result = string;

va_list args
;
va_start
(args,string);

NSString* arg;
while((arg = va_arg(args,NSString*)))
result
= [result stringByAppendingString:arg];

va_end
(args);

return result;
}
Which you would call with something like:
NSString* result = [self concatenateStrings:@"ABC",@"DEF",@"GHI",nil];
Remember to terminate the argument list with a nil.

Leave a Comment