objective c - Index of a character from the NSString in iOS -


i have nsstring example "this question".i want find indices of character/substring "i" ie in case if index starts 0,then want 2,5,16 answer.

the other answer bit of overkill. why don't iterate on characters this:

nsstring *x = @"this question";  (nsuinteger i=0;i<[x length];i++) {     if ([x characteratindex:i]=='i')     {         nslog(@"found: %d", i);     } } 

it outputs positions:

found: 2 found: 5 found: 16 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -