2012年3月25日 星期日

比對字串型別的數字

NSString *num1 = @"2.3";
NSString *num2 = @"2.5";
NSComparisonResult result = [num1 compare:num2 options:NSNumericSearch];
NSLog(@"result %d", result);
-> -1
enum _NSComparisonResult {NSOrderedAscending = -1, NSOrderedSame, NSOrderedDescending};
typedef NSInteger NSComparisonResult;
view raw gistfile1.m hosted with ❤ by GitHub

沒有留言:

張貼留言