Possible Duplicate:
Is there a difference between NSString compare: and isEqual(ToString):?
What is the purpose of using NSOrderedSame in the below line of code?
if([result caseInsensitiveCompare:@"ERROR"]==NSOrderedSame)
where result is a string variable.
The compare methods in Cocoa and Cocoa Touch return how the compared objects should be ordered, instead of just returning a boolean that tells whether the values are the same or not. There are three values:
NSOrderedAscending
: The left operand is smaller than the right operand.NSOrderedSame
: The two operands are equal.NSOrderedDescending
: The left operand is greater than the right operand.
So your code simply checks whether the string pointed to by result
is equal to the string "ERROR", ignoring differences in case (that is, "error", "eRRoR" etc. are all considered to be equal to "ERROR").
精彩评论