I have this BasicNode interface extending NSObject.
At some point, I need to use an instance of it as key to a dictionary:
BasicNode *node = [BasicNode node];
[aMutableDictionary setObject:@"hello" forKey:node]
This crashes the program,”signal SIGABRT”. In Java, a hashmap would call a default hash method on the object to get its key. Is there a mechanism to implement in objC to allow using objects as keys to an NS(Mutbale)Dictionary?
Yes, you can use an NSObject inheritance as Key, but it must implement the
method, and this is the requirement for using as a key.
To implement it your own class is something like this:
This is from this blog post!
Good luck!