
{"id":184,"date":"2007-02-13T21:03:49","date_gmt":"2007-02-13T21:03:49","guid":{"rendered":"http:\/\/www.starcoder.com\/wordpress\/2007\/02\/13\/removing-preferences-belonging-to-your-app\/"},"modified":"2021-10-30T19:59:30","modified_gmt":"2021-10-30T19:59:30","slug":"removing-preferences-belonging-to-your-app","status":"publish","type":"post","link":"https:\/\/www.starcoder.com\/wordpress\/2007\/02\/removing-preferences-belonging-to-your-app\/","title":{"rendered":"Removing preferences belonging to your app&#8230;"},"content":{"rendered":"<p>I was working on some code to uninstall an application, and was pleasantly surprised to find that Cocoa&#8217;s NSUserDefaults class will remove the application&#8217;s preferences file from ~\/Library\/Preferences if you remove all the keys:<\/p>\n<pre style=\"margin-left: 10px;\">NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];\nNSArray *keys = [[defaults dictionaryRepresentation] allKeys];\n\nint i, count = [keys count];\nfor (i = 0; i &lt; count; i++) {\n   [defaults removeObjectForKey:[keys objectAtIndex:i]];\n}\n\n[defaults synchronize];\n<\/pre>\n<p>It&#8217;s not often you find uninstall options for OS X applications, but it&#8217;s nice Apple&#8217;s engineers thought about this case and handle it appropriately.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was working on some code to uninstall an application, and was pleasantly surprised to find that Cocoa&#8217;s NSUserDefaults class will remove the application&#8217;s preferences file from ~\/Library\/Preferences if you remove all the keys: NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSArray *keys = [[defaults dictionaryRepresentation] allKeys]; int i, count = [keys count]; for (i = 0; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-184","post","type-post","status-publish","format-standard","hentry","category-coding","post-preview"],"_links":{"self":[{"href":"https:\/\/www.starcoder.com\/wordpress\/wp-json\/wp\/v2\/posts\/184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.starcoder.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.starcoder.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.starcoder.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.starcoder.com\/wordpress\/wp-json\/wp\/v2\/comments?post=184"}],"version-history":[{"count":1,"href":"https:\/\/www.starcoder.com\/wordpress\/wp-json\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":608,"href":"https:\/\/www.starcoder.com\/wordpress\/wp-json\/wp\/v2\/posts\/184\/revisions\/608"}],"wp:attachment":[{"href":"https:\/\/www.starcoder.com\/wordpress\/wp-json\/wp\/v2\/media?parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.starcoder.com\/wordpress\/wp-json\/wp\/v2\/categories?post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.starcoder.com\/wordpress\/wp-json\/wp\/v2\/tags?post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}