Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Simplicated

macrumors 65816
Original poster
Sep 20, 2008
1,422
254
Waterloo, Ontario, Canada
Hello, I have two strings here

Code:
ABCDEFGH

and another one

Code:
AACCEEGG

I want to compare them, one character at a time.

Is there any ways to achieve this in Obj-C?

Thank you very much.
 
Sure, have a look at NSString's characterAtIndex: method, all you need is an int to keep track of the index as you walk down the string (check the length of both strings first if you can't be sure they'll be the same). If you have C strings instead of Unicode NSStrings, you can easily do it using C pointers and directly comparing the value of each character value.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.