Techniques for implementing -hash on mutable Cocoa objects

后端 未结 6 554
终归单人心
终归单人心 2020-12-31 10:06

The documentation for -hash says it must not change while a mutable object is stored in a collection, and similarly the documentation for -isEqual:

6条回答
  •  失恋的感觉
    2020-12-31 10:27

    In Java, most mutable classes simply don’t override Object.hashCode() so that the default implementation returns a value that is based on the address of the object and doesn’t change. It might just be the same with Objective C.

提交回复
热议问题