Programmatically I can see how many times a character exists in any given string:
letterOccurences= [[tempWordStr componentsSeparatedByString:chosenCharacter] count];
So for the word Mississippi, if the chosen character was ‘i’ this function would return 4.
But what I would like to know is where the character appears in the string. In the Mississippi case, this would be at 1,4,7,10.
You can use the
NSStringmethodrangeOfString:options:range:– this finds and returns the range of a given string (ie,@"i") within a given range. You simply need to adjust the given range of the receiver until you find no more instances of the substring.