Reputation: 2153
I have a ascii code, for the letter 'a', and I want to get a string by its ascii code, is it possible with NSString?
Upvotes: 0
Views: 4089
Reputation: 104065
This could also work:
NSString *foo = [NSString stringWithFormat:@"%c", 97];
Didn’t test it.
Upvotes: 7
Reputation: 237010
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];
Upvotes: 4