-[NSObject isEqual:] and -[NSNumber isEqualToNumber:]: what's the difference?

objective-c

Solution

From the docs:

Two NSNumber objects are considered equal if they have the same id values or if they have equivalent values (as determined by the compare: method). This method is more efficient than compare: if you know the two objects are numbers.

So it handles id equals and number comparison.

Problem

Both methods return equal results. Of course, `-[NSObject isEqual:]` doesn't compare the pointers of objects, it somehow check the inner fields or whatever. So what's the point of using exactly `-[NSNumber isEqualToNumber:]` to compare two `NSNumber`s?

Original source