问题
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