-
Notifications
You must be signed in to change notification settings - Fork 2
/
NSUserDefaults+Additions.m
37 lines (26 loc) · 1.03 KB
/
NSUserDefaults+Additions.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// NSUserDefaults+Additions.m
// Additions
//
// Created by jlopez on 2/26/10.
// Copyright 2010 JLA. All rights reserved.
//
#import "NSUserDefaults+Additions.h"
@implementation NSUserDefaults (JLAdditions)
+ (void)setupDefaults {
NSMutableDictionary *defaults = [NSMutableDictionary dictionaryWithCapacity:8];
//Get the bundle path
NSString *plistFile = [[NSBundle mainBundle] pathForResource:@"Root" ofType:@"plist" inDirectory:@"Settings.bundle"];
//Get the Preferences Array from the dictionary
NSDictionary *settingsDictionary = [NSDictionary dictionaryWithContentsOfFile:plistFile];
NSArray *preferencesArray = [settingsDictionary objectForKey:@"PreferenceSpecifiers"];
for (id specifier in preferencesArray) {
NSString *key = [specifier objectForKey:@"Key"];
NSString *defaultValue = [specifier objectForKey:@"DefaultValue"];
if (key && defaultValue)
[defaults setObject:defaultValue forKey:key];
}
// Register defaults
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
}
@end