Created
October 3, 2011 21:18
-
-
Save chockenberry/1260280 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)loadDefaultSettings | |
{ | |
NSMutableDictionary *defaults = [NSMutableDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default-Settings" ofType:@"plist"]]; | |
// other setup... | |
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithDictionary:defaults]]; | |
} | |
- (void)resetDefaultSettings | |
{ | |
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | |
NSString *bundleIdentifer = [[NSBundle mainBundle] bundleIdentifier]; | |
NSDictionary *persistentDomain = [userDefaults persistentDomainForName:bundleIdentifer]; | |
for (NSString *key in [persistentDomain allKeys]) { | |
[userDefaults removeObjectForKey:key]; | |
} | |
} | |
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification | |
{ | |
DebugLog(@"%s called", __PRETTY_FUNCTION__); | |
if ([NSEvent modifierFlags] == NSShiftKeyMask) { | |
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"DefaultsResetText", nil) defaultButton:NSLocalizedString(@"Cancel", nil) alternateButton:NSLocalizedString(@"OK", nil) otherButton:nil informativeTextWithFormat:NSLocalizedString(@"DefaultsResetDescription", nil)]; | |
NSInteger returnCode = [alert runModal]; | |
if (returnCode == NSAlertAlternateReturn) { | |
[self resetDefaultSettings]; | |
} | |
} | |
[self loadDefaultSettings]; | |
// other setup... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment