Python has string.startswith() and string.endswith() functions which are pretty useful. What NSString methods can I use to have the same function?<
string.startswith()
string.endswith()
Use -hasPrefix: and -hasSuffix::
NSString *s = @"foobar"; NSLog(@"%d %d\n", [s hasPrefix:@"foo"], [s hasSuffix:@"bar"]); // Output: "1 1"