两种方法都返回相同的结果当然,– [NSObject isEqual:]不会比较对象的指针,它会以某种方式检查内部字段或其他内容.那么准确地使用什么 – [NSNumber isEqualToNumber:]来比较两个NSNumber呢?
解决方法
从
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.
所以它处理id等于和数字比较.