码迷,mamicode.com
首页 > 其他好文 > 详细

字符串比较 忽略大小写 iphone

时间:2014-07-14 17:52:38      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   io   div   

//不考虑大小写比较字符串1

NSString *astring01 = @"this is a String!";
    NSString *astring02 = @"This is a String!";
    BOOL result = [astring01 caseInsensitiveCompare:astring02] = = NSOrderedSame;    
    NSLog(@"result:%d",result);    
    //NSOrderedDescending判断两对象值的大小(按字母顺序进行比较,astring02小于astring01为 真)

//不考虑大小写比较字符串2

 NSString *astring01 = @"this is a String!";
    NSString *astring02 = @"This is a String!";
    BOOL result = [astring01 compare:astring02
                            options:NSCaseInsensitiveSearch | NSNumericSearch] = = NSOrderedSame;    
    NSLog(@"result:%d",result);    

    //NSCaseInsensitiveSearch:不区分大小写比较 NSLiteralSearch:进行完全比较,区分大小写 NSNumericSearch:比较字符串的字符个数,而不是字符值。

 

字符串比较 忽略大小写 iphone,布布扣,bubuko.com

字符串比较 忽略大小写 iphone

标签:des   style   blog   color   io   div   

原文地址:http://www.cnblogs.com/savagemorgan/p/3842895.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!