gpt4 book ai didi

objective-c - -[NSObject 等于 :] and -[NSNumber isEqualToNumber:]: what's the difference?

转载 作者:太空狗 更新时间:2023-10-30 03:36:52 32 4
gpt4 key购买 nike

两种方法返回相同的结果。当然,-[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 等于和数字比较。

关于objective-c - -[NSObject 等于 :] and -[NSNumber isEqualToNumber:]: what's the difference?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13783404/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com