Posted By

zingo on 07/22/08


Tagged

cocoa osx preferences


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

davidsi
avanadra
Tintenklecks
cnathan


Removing preferences belonging to your app


 / Published in: Objective C
 

URL: http://www.starcoder.com/wordpress/2007/02/13/removing-preferences-belonging-to-your-app/

Remove all the keys of the application’s preferences file from ~/Library/Preferences with Cocoa’s NSUserDefaults class.

  1. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  2. NSArray *keys = [[defaults dictionaryRepresentation] allKeys];
  3.  
  4. int i, count = [keys count];
  5. for (i = 0; i < count; i++) {
  6. [defaults removeObjectForKey:[keys objectAtIndex:i]];
  7. }
  8.  
  9. [defaults synchronize];

Report this snippet  

You need to login to post a comment.