Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appending unichar to NSMutableString

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...

like image 424
mllm Avatar asked Mar 30 '15 22:03

mllm


1 Answers

Use [NSString appendFormat:], so for above:

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

Enjoy!

like image 58
mllm Avatar answered Oct 16 '22 19:10

mllm