Is an NSMapTable the same as an NSMutableDictionary except for allowing keys to be pointers?
Does it differ in memory management?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The main difference between NSMapTable and NSMutableDictionary is that NSMapTable stores weak pointers. This means that when you call smth like this:
the value and key are not retained (it means no retain message is sent to them). That’s why you can use any object (or maybe not object but any pointer) cause they don’t have to respond to retain message.
So you probably want to use NSMapTable if you’re using garbage collection where you don’t need to bother about retain count of an object.