PDA

View Full Version : I need a way to see if an NSString is contains by another




ausername
Apr 13, 2009, 08:22 PM
Hello, I am looking for a way to tell if a string contains another string. Something like this...

if ([thisLetter isIn: theParagraph]) {

... //do something

}


or maybe:
if ([theParagraph contains: thisLetter]) {

... //do something

}

but sadly those are not real methods... So, does anyone know of a way to do this? any help would be great, thanks. :)



Guiyon
Apr 13, 2009, 08:40 PM
I'd suggest reading the section of the NSString class documentation titled "Finding Characters and Substrings". While there isn't an explicit boolean "contains:" method, there are several that should be close enough, with a little logic.