We Recommend

Programming in Objective-C Programming in Objective-C
Programming in Objective-C is a concise, carefully written tutorial on the basics of Objective-C and object-oriented programming. The book makes no assumption about prior experience with object-oriented programming languages or with the C language (upon which Objective-C is based). And because of this, both novice and experienced programmers alike can use this book to quickly and effectively learn the fundamentals of Objective-C.


Posted By

zingo on 07/22/08


Tagged

cocoa osx preferences


Versions (?)


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.