How to compare objects using operator < or > in Objective-C?
How do I compare two objects of a custom class in Objective-C? I try to overloading the - (NSComparisonResult)compare:(id)other; method. This works great if I call the method manually if ([obj1 compare:obj2] == NSOrderedDescending) { // do something } Is there any way that I can do it like this? if (obj1 > obj2) { // do something } Or is there another method that I need to overload? This is not possible, since objective C doesn't have operator overloading. You are comparing pointer values. One way to achieve this is for your class you can define comparisons to everything that make sense to