I tried to search on Google or Stackoverflow but can’t find such an operator. In C we used to defined a cmp macro but is there something built in?
I tried to search on Google or Stackoverflow but can’t find such an operator.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As @Kashiv mentioned, 100% of C is available in Objective-C. However, if you are using the Cocoa Frameworks and are asking about a more “Cocoa” way of doing it, NSNumber has a compare: method, which returns an NSComparisonResult, which is either -1, 0 or 1.
However, if we are being thoroughly Cocoa in our programming we should further abstract ourselves from the specific knowledge of -1, 0 and 1 and use the constants NSOrderedAscending, NSOrderedSame, and NSOrderedDescending. These are semantically named and that’s the real value in programming this way.