pro*_*eek 45 python cocoa objective-c
Python有string.startswith()和string.endswith()功能,这是非常有用的.我可以使用哪些NSString方法来实现相同的功能?
Ada*_*eld 62
NSString *s = @"foobar";
NSLog(@"%d %d\n", [s hasPrefix:@"foo"], [s hasSuffix:@"bar"]);
// Output: "1 1"
Run Code Online (Sandbox Code Playgroud)
-hasPrefix()和-hasSuffix()返回YES或NO,具体取决于接收者是以给定子字符串开头还是结尾.如果那是startswith()和endswith()那么,那就是你的答案.
| 归档时间: |
|
| 查看次数: |
7261 次 |
| 最近记录: |