Alex Rivera | Logout

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

Asked 2011-03-05T05:44:01.957
46

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

Edit
Report

1 Answer

5

-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.

answered 2011-03-05T05:53:32.233

Your Answer