What is the use of NSOrderedSame?

Possible duplicate:
Is there a difference between NSString compare: and isEqual (ToString) :?

What is the purpose of using NSOrderedSame in the next line of code?

if([result caseInsensitiveCompare:@"ERROR"]==NSOrderedSame) 

where result is a string variable.

+7
source share
1 answer

Comparison methods in Cocoa and Cocoa Touch return a way to arrange the objects to be compared instead of simply returning a boolean value indicating whether these values โ€‹โ€‹are the same or not. There are three meanings:

  • NSOrderedAscending : The left operand is smaller than the right operand.
  • NSOrderedSame : Two operands are equal.
  • NSOrderedDescending : The left operand is larger than the right operand.

That way, your code just checks to see if the line that result points to is the ERROR line, ignoring the differences in the case (that is, "error", "eRRoR", etc., all are considered equal to "ERROR").

+24
source

All Articles