Jonathan.
Jonathan.

Reputation: 55604

Combine string in objectivec

How do I concenate 2 strings in objective-c, like in VB.net you can just do "foo" & "bar"

Upvotes: 1

Views: 673

Answers (1)

Vladimir
Vladimir

Reputation: 170849

NSString *newString = [@"foo" stringByAppendingString:@"bar"];

If you're going to change your string frequently consider using its mutable variant - NSMutableString which allows to append strings without creating new instance:

NSMutableString *mutString = [NSMutableString stringWithString:@"foo"];
[mutString appendString:@"bar"];

Upvotes: 12

Related Questions