Objective-C (cocoa) equivalent to python's endswith/beginswith

后端 未结 3 1738
遇见更好的自我
遇见更好的自我 2021-01-17 09:37

Python has string.startswith() and string.endswith() functions which are pretty useful. What NSString methods can I use to have the same function?<

3条回答
  •  遇见更好的自我
    2021-01-17 10:05

    You want the hasPrefix and hasSuffix messages.

    I tend to also use the compare:options: message pretty regularly to achieve the same but with case-insensitive comparison.

提交回复
热议问题