I’m trying to create an NSDictionary that keeps track of calling objects for a function. I’d like to create a unique string for each object without knowing anything about it. My first thought is to use the memory address of the object’s pointer, but I’m not sure how to do that.
Any thoughts? I need to use some sort of unique id from an NSObject as the keys in my dictionary.
While I agree that your solution sounds like it may not be the best approach, have you considered
-hashin theNSObjectprotocol? AllNSObjectsshould return one. Be forewarned that it’s a hash, so there’s a chance that two different objects could have the same hash.You could also consider a category on
NSObjectthat your collection implements. The category could generate a UUID to use as a key.