I am trying to convert a piece of Java code which uses a HashMap that contains as a key an object and a value as an object.
private static HashMap<Class<? extends Component>, ComponentType> componentTypes = new HashMap<Class<? extends Component>, ComponentType>();
I’ve been reading on how to do this with Obj-C but I have not been successful, most people suggest using a NSDictionary, the problem is that they keys need to be strings and I need them as objects. The other option was NSMapTable, however it is not available on iOS. Would someone be able to assist on how I can convert this into an obj-c equivalent?
thanks,
The keys for an
NSDictionarydo not need to be strings. They can be any object that implementsNSCopying. If the object is a custom object, however, it needs to produce sane responses to the-hashand-isEqual:messages, but this is the same as using an object in a Java collection so it shouldn’t be much of a challenge.