Detecting if an NSString contains…?

后端 未结 7 2082
长情又很酷
长情又很酷 2021-01-30 03:37

How can I detect if a string contains a certain word? For example, I have a string below which reads:

@\"Here is my string.\"

I\'d like to know

7条回答
  •  鱼传尺愫
    2021-01-30 04:10

    In iOS8 you can now use:

    BOOL containsString = [@"Here is my string." containsString:@"is"];
    

    There's an interesting post on how to "retrofit" it to iOS7 here: http://petersteinberger.com/blog/2014/retrofitting-containsstring-on-ios-7/

提交回复
热议问题