#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
//判断字符串是否有此前缀
NSString *str=@"IOS8-赵玉鑫.jpg";
BOOL result = [str hasPrefix:@"IOS"];
NSLog(@"%d",result);
//判断字符串是否有此后缀
BOOL resultsu = [str hasSuffix:@".jpg"];
NSLog(@"%d",resultsu);
}
return 0;
}
原文:http://www.cnblogs.com/LiHai/p/5118038.html