Pearls of Objective-c NSMutableDictionary (iPhone Development):

NSMutableDictionary does not seem to store my data but I do not get any error when setting or getting the data, what is the issue?

In almost all cases, in objective-c, all the variables need to be initialized before using them. The iphone program crashes horribly when the program come across un-initialized variables. However, there are exception to this rule. One such case is NSMutableDictionary typed object.

An un-initialized NSMutableDictionary does not crash the application or throw any type of exception when doing operation on the variable. You will be able to set and get objects without any issue. The only program is that nothing happens.

You think that you put something in the Dictionary but nothing gets stored on it. So, you wonder if there are issue with retain which takes you down different pathway on debugging the issue.

The issue here is that NSMutableDictionary is not initialized yet. So, the operation that you did is on a “nil” object. However, the application does not throw any exception.

Thus, if you come across this case, make sure you check if you have done the initialization on the NSMutableDictionary variable.