iphone - Verify the existence of a word in an NSString -


I searched a bit, but this (probably very simple) question could not be answered.

I have an NSString, and I want to see if there is a word in it or not. Something like this:

  NSString * sentence = @ "Quick brown fox"; NSString * word = @ "quack"; If (word in sentence:)) {nslog (@ "yes it contains that word"); }  

Thanks.

The following should be done:

  NSString * sentence = @ " Quick Brown Fox "; NSString * word = @ "quack"; If ([sentence limitation opstring: word]. Location! = NSNotFound) {NSLog (@ "yes that includes that word"); }  

It uses the rangeOfString: to return a NSRange structure, which indicates the location of the word, If it can not be found, it will be equal to NSRange.location NSNotFound .


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -