{"id":113,"date":"2009-10-20T02:45:01","date_gmt":"2009-10-20T02:45:01","guid":{"rendered":"http:\/\/shirishranjit.com\/blog1\/?p=113"},"modified":"2015-07-25T09:17:32","modified_gmt":"2015-07-25T13:17:32","slug":"pearls-of-objective-c-nsmutabledictionary-iphone-development","status":"publish","type":"page","link":"https:\/\/shirishranjit.com\/blog1\/pictures\/pearls-of-objective-c-nsmutabledictionary-iphone-development","title":{"rendered":"Pearls of Objective-c NSMutableDictionary (iPhone Development):"},"content":{"rendered":"<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Verdana;\"><strong><br \/>\n<\/strong><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; text-align: justify; font: 10.0px Verdana;\"><span style=\"letter-spacing: 0.0px;\">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?<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; text-align: justify; font: 10.0px Verdana;\"><span style=\"letter-spacing: 0.0px;\">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. <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; text-align: justify; font: 10.0px Verdana;\"><span style=\"letter-spacing: 0.0px;\">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. <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; text-align: justify; font: 10.0px Verdana;\"><span style=\"letter-spacing: 0.0px;\">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.<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; text-align: justify; font: 10.0px Verdana;\"><span style=\"letter-spacing: 0.0px;\">The issue here is that NSMutableDictionary is not initialized yet. So, the operation that you did is on a \u201cnil\u201d object. However, the application does not throw any exception. <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; text-align: justify; font: 10.0px Verdana;\"><span style=\"letter-spacing: 0.0px;\">Thus, if you come across this case, make sure you check if you have done the initialization on the NSMutableDictionary variable.<\/span><\/p>\n<div style=\"text-align: justify;\"><span style=\"font-family: Verdana, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: x-small;\"><span style=\"line-height: normal;\"><br \/>\n<\/span><\/span><\/div>\n<div class=\"twttr_buttons\"><div class=\"twttr_twitter\">\n\t\t\t\t\t<a href=\"http:\/\/twitter.com\/share?text=Pearls+of+Objective-c+NSMutableDictionary+%28iPhone+Development%29%3A\" class=\"twitter-share-button\" data-via=\"\" data-hashtags=\"\"  data-size=\"default\" data-url=\"https:\/\/shirishranjit.com\/blog1\/pictures\/pearls-of-objective-c-nsmutabledictionary-iphone-development\"  data-related=\"\" target=\"_blank\">Tweet<\/a>\n\t\t\t\t<\/div><div class=\"twttr_followme\">\n\t\t\t\t\t\t<a href=\"https:\/\/twitter.com\/shiranjit\" class=\"twitter-follow-button\" data-size=\"default\"  data-show-screen-name=\"false\"  target=\"_blank\">Follow me<\/a>\n\t\t\t\t\t<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/shirishranjit.com\/blog1\/pictures\/pearls-of-objective-c-nsmutabledictionary-iphone-development\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":91,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-113","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/113"}],"collection":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/comments?post=113"}],"version-history":[{"count":4,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/113\/revisions"}],"predecessor-version":[{"id":1004,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/113\/revisions\/1004"}],"up":[{"embeddable":true,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/91"}],"wp:attachment":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/media?parent=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}