84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
今天在看以前写的代码的时候,发现在比较两个NSNumber大小的时候直接写成了 a > b(ab都是NSNumber对象),竟然没有保存,结果也符合预期。可以似乎对象之间不能直接用关系运算符比较,而是应该使用compare:方法啊。有人注意到这一点吗?
compare:
ringa_lee
Is it swift? If so the operator may be overloaded.
If it’s OC, it’s a coincidence:) It’s probably two pointer addresses that are being compared.
Is it swift? If so the operator may be overloaded.
If it’s OC, it’s a coincidence:) It’s probably two pointer addresses that are being compared.