objective-c concatenate NSString

ぐ巨炮叔叔 提交于 2019-12-01 17:02:50

So you can certainly use stringWithFormat, but why don't you use stringByAppendingString instead, since that's exactly what you want to do?

NSString *newString = [firstString stringByAppendingString:secondString];

You really don't need to use a mutable string unless you have a compelling reason to.

Not sure what exactly you want to do. But as per your code aux will have new buttonIndex value each time and You will have always new mystring when ever you tap button.

If you want to append string always in myString that you need to do like this.

myString=[NSString stringWithFormat:@"%@%@/%@",myString,posTargetaText,aux];

You suppose to add previous value of myString as well in new myString string ?

Not sure this is what you want or something different. Please explain in detail if this is not.

If you wanna concatenate two strings use NSMutablestring and method appendstring instead of NSString.

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSMutableString_Class/Reference/Reference.html

You need to use NSMutableString.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!