mirror of
https://github.com/nickshanks/ResKnife.git
synced 2024-10-03 20:55:36 +00:00
Use -registerDefaults:, man.
This commit is contained in:
parent
0bb0ce7f51
commit
e3017f5f9e
@ -194,31 +194,17 @@
|
||||
// from the app wrapper, and then sets the defaults if they don't
|
||||
// already exist.
|
||||
|
||||
NSUserDefaults *defaults;
|
||||
NSDictionary *defaultsPlist;
|
||||
NSEnumerator *overDefaults;
|
||||
id eachDefault;
|
||||
|
||||
// this isn't required, but saves us a few method calls
|
||||
defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
// load the defaults.plist from the app wrapper. This makes it
|
||||
// easy to add new defaults just using a text editor instead of
|
||||
// hard-coding them into the application
|
||||
defaultsPlist = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"defaults" ofType:@"plist"]];
|
||||
NSDictionary *defaultsPlist = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"defaults" ofType:@"plist"]];
|
||||
|
||||
// enumerate over all the keys in the dictionary
|
||||
overDefaults = [[defaultsPlist allKeys] objectEnumerator];
|
||||
while(eachDefault = [overDefaults nextObject])
|
||||
{
|
||||
// for each key in the dictionary
|
||||
// check if there is a value already registered for it
|
||||
// and if there isn't, then register the value that was in the file
|
||||
if(![defaults stringForKey:eachDefault])
|
||||
{
|
||||
[defaults setObject:[defaultsPlist objectForKey:eachDefault] forKey:eachDefault];
|
||||
}
|
||||
}
|
||||
|
||||
[defaults registerDefaults:defaultsPlist];
|
||||
|
||||
// force the defaults to save to the disk
|
||||
[defaults synchronize];
|
||||
|
Loading…
Reference in New Issue
Block a user