// get pre-set value
-(NSDictionary*)settingsBundleDefaultValues
{
NSMutableDictionary *defaultDic_ = [[NSMutableDictionary alloc]init];
NSURL *settingsUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Root"
ofType:@"plist"
inDirectory:@"Settings.bundle"] isDirectory:YES];
NSDictionary *settingBundle = [NSDictionary dictionaryWithContentsOfURL:settingsUrl];
NSArray *preference_ = [settingBundle objectForKey:@"PreferenceSpecifiers"];
for (NSDictionary *component_ in preference_) {
NSString *key = [component_ objectForKey:@"Key"];
NSString *defaultValue = [component_ objectForKey:@"DefaultValue"];
if (!key||!defaultValue) continue;
if (![component_ objectForKey:key]) {
[defaultDic_ setObject:[component_ objectForKey:@"DefaultValue"] forKey:key];
}
}
return defaultDic_;
}
// get
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
// this step need to code
[userDefault registerDefaults:[self settingsBundleDefaultValues]];
NSString *text = [userDefault stringForKey:@"key-name"];