2

I'm wondering if I can use the hashValue of an UIViewController to uniquely identify an instance of a UIViewController during runtime.

I tried to create a UIViewController and modify some of its properties and the hasValue stays the same. It seems like the hashValue is not changing during runtime but I want to be sure and I didn't find 'how its been generated' in the documentation.

Does anyone know if its based on the starting memoryAddress? Can the hashValue change during runtime?

Michael
  • 1,030
  • 14
  • 29
  • 2
    UIViewController inherits from NSObject, and its hash value *is* the memory address (compare https://stackoverflow.com/a/38946892/1187415). And it is a reference type, therefore changing the properties does not mutate the reference. – Martin R Dec 08 '18 at 13:56
  • awesome! Thx a lot! – Michael Dec 08 '18 at 14:00
  • Possible duplicate of [Difference between Swift's hash and hashValue](https://stackoverflow.com/questions/38946690/difference-between-swifts-hash-and-hashvalue) – denis_lor Apr 18 '19 at 20:17

0 Answers0