Removing preferences belonging to your app


/ Published in: Objective C
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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];

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.