Objective-c use CharacterAtIndex

character, indexing, nsstring, objective-c

Solution

`characterAtIndex` returns a char, not NSString object, so do this kind of thing instead,

if ([a characterAtIndex:i] == 'v') 

Problem

I want to use `characterAtIndex` in Objective-C to compare the character at a certain position and a character ('v' for example). The problem is that `characterAtIndex` seems to send an int and not a character. I tried to do something like this: ``` if ([string characterAtIndex:i] = @"v") ``` or also: ``` if (string[[string characterAtIndex:i]] .... ) ``` I know that in some language you can go directly to a certain position in the string (like an array) to see the character, but it doesn't seems to work that way in Objective-C. Thanks for you help !

Original source