开发者

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜