Objective-c: how to convert int to NSString

I use the following code to get the alphabetical number of the first letter in a string:

toupper([ my_string characterAtIndex: 0 ] ) - 'A'

I need to do the inverse problem - convert the alphabetic number of a letter to NSString.

What is the best way to do this?

Thanks in advance.

+3
source share
1 answer

Use stringWithFormat::

// 0 ==> @"A", 25 ==> @"Z"
NSString *str = [NSString stringWithFormat:@"%c", theCharIndex + 'A'];

edited to include string identifier @

+11
source

Source: https://habr.com/ru/post/1707501/


All Articles