I\'m trying to loop through a NSString, character by character, but I\'m getting a EXC_BAD_ACCESS error. Do you have an idea how to do this right? I\'ve been googling for hours
characterAtIndex:
returns a unichar
, so you should use NSLog(@"%C", ...)
instead of @"%@"
.
You also cannot use isEqualToString
for a unichar
, just use == '.'
is fine.
If you want to find the position of all '.'s, you can use rangeOfString
. Refer to: