tags:

views:

1400

answers:

1

Hi, 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.

+7  A: 

Use stringWithFormat::

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