Appending unichar to NSMutableString

二次信任 提交于 2020-01-02 02:24:07

问题


How do you append a unichar character to NSMutableString?

unichar c = 'T';
NSMutableString *s = [NSMutableString stringWithString:@"MyString"];

// want s to become "MyStringT"

https://discussions.apple.com/thread/1679290 suggests:

[s appendString:[NSString stringWithCharacters:&c length:1]];

Looks too long / complicated...


回答1:


Use [NSString appendFormat:], so for above:

[s appendFormat:@"%C", c];

Enjoy!



来源:https://stackoverflow.com/questions/29357205/appending-unichar-to-nsmutablestring

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