NSString比較サイズ



Nsstring Compare Size



//compare method (the three values ​​returned by the comparator) NSString *astring01 = @'This is a String!' NSString *astring02 = @'This is a String!' BOOL result = [astring01 compare:astring02] = = NSOrderedSame NSLog(@'result:%d',result) //NSOrderedSame determines if the two contents are the same NSString *astring01 = @'This is a String!' NSString *astring02 = @'this is a String!' BOOL result = [astring01 compare:astring02] = = NSOrderedAscending NSLog(@'result:%d',result) //NSOrderedAscending determines the size of the two object values ​​(compared in alphabetical order, astring02 is greater than astring01 is true) NSString *astring01 = @'this is a String!' NSString *astring02 = @'This is a String!' BOOL result = [astring01 compare:astring02] = = NSOrderedDescending NSLog(@'result:%d',result) //NSOrderedDescending determines the size of the two object values ​​(compared in alphabetical order, astring02 is less than astring01 is true) / / Do not consider the upper and lower case comparison string 1 NSString *astring01 = @'this is a String!' NSString *astring02 = @'This is a String!' BOOL result = [astring01 caseInsensitiveCompare:astring02] = = NSOrderedSame NSLog(@'result:%d',result) //NSOrderedDescending determines the size of the two object values ​​(compared in alphabetical order, astring02 is less than astring01 is true) / / Do not consider the case comparison string 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: Case-insensitive comparison NSLiteralSearch: Make a full comparison, case sensitive NSNumericSearch: Compare the number of characters in a string, not a character value.