判断字符串是否有此前缀和后缀

#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;

}

原文地址:https://www.cnblogs.com/jidezhi/p/5120713.html