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.
iOS: Concat NSString iOS: Concat NSString Reviewed by Unknown on 15:13 Rating: 5

No hay comentarios:

Con la tecnología de Blogger.