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

后端 未结 3 1693
遇见更好的自我
遇见更好的自我 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:11

    -hasPrefix() and -hasSuffix() return YES or NO depending on whether the receiver begins or ends with the given substring. If that's what startswith() and endswith() do, then that's your answer.

提交回复
热议问题