将unichar附加到NSMutableString

时间:2015-03-30 22:06:46

标签: objective-c nsstring char nsmutablestring unichar

如何将unichar字符附加到NSMutableString

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

// want s to become "MyStringT"

https://discussions.apple.com/thread/1679290建议:

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

看起来太长/太复杂......

1 个答案:

答案 0 :(得分:8)

使用[NSString appendFormat:],所以对于上面的内容:

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

享受!