Q:

How do I break a text string down to two letter chunks, and convert those chunks to four digit numbers in Objective-C?

I want to make a simple program for my number theory class. We're learning encryption.
The main encryption I want to demonstrate is demonstrated in this example:
Take the phrase "TAKE CARE"
as 
TA
KE
-C
AR
E-
where TA is converted to 2001, because T is the 20th letter in the alphabet and A is the first.

A:

Well, since you seem to be limiting yourself to ASCII, then you should be fine using the -UTF8String of the string:
NSString *source = @"TAKE CARE";
source = [source lowercaseString]; //normalize the capitalization
const char *characters = [source UTF8String];
for (NSUInteger i = 0; i < [source length]; ++i) {
  const char character = characters[i];
  if (character >= 'a' && character <= 'z') {
    int positionInAlphabet = character - 'a' + 1; // this means "a" is "1"
    NSLog(@"%c = %d", character, positionInAlphabet);
  } else {
    NSLog(@"non-letter: %c", character);
  }
}

