Detecting if an NSString contains…?

后端 未结 7 2094
长情又很酷
长情又很酷 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:05

    With iOS 8 and Swift, we can use localizedCaseInsensitiveContainsString method

     let string: NSString = "Café"
     let substring: NSString = "É"
    
     string.localizedCaseInsensitiveContainsString(substring) // true
    

提交回复
热议问题