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

 

 

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

}

 

posted @ 2016-01-11 12:00  哎呦喂i  阅读(1575)  评论(0编辑  收藏  举报