Reputation: 53560
I am using the following code to get an alphabetic number of a first letter in a string:
toupper([ my_string characterAtIndex: 0 ] ) - 'A'
I need to do an inverse task - to convert an alphabetical number of a letter to a NSString.
What is the best way to do so?
Thank you in advance.
Upvotes: 3
Views: 6247
Reputation: 400592
Use stringWithFormat:
:
// 0 ==> @"A", 25 ==> @"Z"
NSString *str = [NSString stringWithFormat:@"%c", theCharIndex + 'A'];
edited to include string identifier @
Upvotes: 11