我有一个名为 'you' 的 NSString,其值为 "This is a you string!"。
我想在'you'中连接“123”,我该怎么做?
我正在使用此代码,但它给出了错误。
you=[you stringByAppendingString:@"123"];
最佳答案
这里的代码对我有用
NSString *s = @"avant";
s = [s stringByAppendingString:@" - après"];
NSLog(@"%@", s);
2012-01-13 11:48:59.442 tabbar[604:207] avant - après
所以我猜你的 you
是一个坏指针,它不是 nil
也不是你认为的 NSString。
您在调用之前是否尝试过对该值的 NSLog?
关于objective-c - Objective C中的简单字符串连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8853865/