Objective C 中的简单字符串连接
我有一个名为“you”的 NSString,其值为“这是一个 you 字符串!”。
我想在“你”中连接“123”,我该怎么做?
我正在使用这段代码,但它给出了一个错误。
you=[you stringByAppendingString:@"123"];
I have an NSString named 'you' with value "This is a you string!".
I want to concat "123" in 'you', how can I do it?
I am using this code and it is giving an error.
you=[you stringByAppendingString:@"123"];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这里的代码对我有用
所以我的猜测是你的
you
是一个坏指针,不是nil
并且不是你认为它有的 NSString 。您在调用之前是否尝试过对该值进行 NSLog ?
This code here is working for me
So my guess is that your
you
is a bad pointer that is notnil
and not the NSString you think it have.Have you try an NSLog on that value before the call?
你也可以尝试这个:
You can try this also:
代码:
控制台结果:
[233:907] 你:这是你的字符串!
[233:907] 你 : 这是你 String!123
[233:907] 你 : 这是你 String!123
Code :
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
请尝试这个
Please try this