Simple string concatenation in Objective C Simple string concatenation in Objective C objective-c objective-c

Simple string concatenation in Objective C


This code here is working for me

NSString *s = @"avant";s = [s stringByAppendingString:@" - après"];NSLog(@"%@", s);

2012-01-13 11:48:59.442 tabbar[604:207] avant - après

So my guess is that your you is a bad pointer that is not nil and not the NSString you think it have.

Have you try an NSLog on that value before the call?


You can try this also:

you = [NSString stringWithFormat:@"%@%@", you, @"123"];


Code :

NSString *you;you = @"This is you String!";NSLog(@"you : %@ ",you);you = [you stringByAppendingString:@"123"]; NSLog(@"you : %@ ",you);[you stringByAppendingFormat:@"%@%@",you,@"123"];NSLog(@"you : %@ ",you);

Result in Console :

[233:907] you : This is you String!

[233:907] you : This is you String!123

[233:907] you : This is you String!123