objective-c – – [NSObject isEqual:]和 – [NSNumber isEqualToNumber:]:有什么区别?

前端之家收集整理的这篇文章主要介绍了objective-c – – [NSObject isEqual:]和 – [NSNumber isEqualToNumber:]:有什么区别?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
两种方法都返回相同的结果当然,– [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等于和数字比较.

原文链接:https://www.f2er.com/c/110842.html

猜你在找的C&C++相关文章