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];
  4. int i, count = [keys count];
  5. for (i = 0; i < count; i++) {
  6. [defaults removeObjectForKey:[keys objectAtIndex:i]];
  7. }
  9. [defaults synchronize];


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.