views:

59

answers:

2

Hi,

Is the a way to get the NSRange of an NSString in an NSString?

+3  A: 

Did you look in the documentation?

NSString has the following method:

- (NSRange)rangeOfString:(NSString *)aString

The NSString class reference at developer.apple.com says of this method:

Finds and returns the range of the first occurrence of a given string within the receiver.

harms
Oops. That should have been obvious. Thank you!
Jess
Also note that there are some other methods that do largely the same, but the one I mentioned is the most basic one. The documentation explains the differences.
harms
+1  A: 

You're making this up, right? Or is there some hidden clue in your question that makes rangeOfString: the wrong answer?

Nikolai Ruhe
I'm so so sorry... I really didn't see that method. Thank you!
Jess
Apologies accepted. Now accept one of the answers!
Nikolai Ruhe