NSString *url = @"http://ios.itcast.cn";
NSString *url2 = @"https://ios.itcast.cn";
NSComparisonResult result = [url compare:url2 options:NSNumericSearch | NSCaseInsensitiveSearch ];
switch (result) {
case NSOrderedAscending:
NSLog(@"url < url2");
break;
case NSOrderedDescending:
NSLog(@"url > url2");
break;
case NSOrderedSame:
NSLog(@"url = url2");
default:
break;
}
如果是NSOBject排序,能否封装一个排序方法呢
if ([url isEqualTo:url2 ]) {
NSLog(@"相等");
} else {
NSLog(@"不相等");
}
|
|