Create an enum with all the letters. Then loop through the input string one character at a time, and add up the values.
enum {
A=1,
B=2,
C=3,
// etc...
};
typedef int AlphabetIntCodes;
Then loop through using something like:
NSMutableString *textString = [[NSMutableString alloc] initWithString:txtText.text];
NSString *string = [NSMutableString stringWithFormat:@"%@",textString];
int stringLength = textString.length;
for (int i=0; i<stringLength; i++) {
string = [string characterAtIndex:i];
// Find the int value from the enum, and add it to a variable...
}
See looping through enum values to find the int values of each letter.
You don't have to use an enum, you could also just create a new AlphabetLetter NSObject class, and have two properties, the letter, and the int representation, and add them to an NSArray, and lookup the values of each letter through the array of AlphabetLetters.