Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object pointer value as key into dictionary

I want to use the object's reference value as a key into a dictionary, as opposed to a copy of value of the object. So, I essentially want to store an object associated with a particular instance of another object in a dictionary and retrieve that value later.

Is this possible? Is it completely against the idea of NSDictionary? I can tell that I am probably approaching this the wrong way because the dictionary wants me to implement NSCopying on the object itself, which doesn't really make sense in terms of what I'm doing. I can see that what I should really be doing is wrapping the pointer value, but that seems a little mad.

Advice would be appreciated.

like image 762
Ranking Stackingblocks Avatar asked Apr 25 '10 12:04

Ranking Stackingblocks


1 Answers

I think you can use [NSValue valueWithPointer:object].

like image 86
hooleyhoop Avatar answered Nov 05 '22 08:11

hooleyhoop