Get a string with ascii code objective-c
I have a ascii code, for the letter 'a', and I want to get a st开发者_StackOverflow中文版ring by its ascii code, is it possible with NSString?
This could also work:
NSString *foo = [NSString stringWithFormat:@"%c", 97];
Didn’t test it.
If you mean you have a byte that represents an ASCII-encoded character and you want to make a string out of it, NSString has an initializer just for that.
char characterCodeInASCII = 97;
NSString *stringWithAInIt = [[NSString alloc] initWithBytes:&characterCodeInASCII length:1 encoding:NSASCIIStringEncoding];
精彩评论