我有一个文件在从的appDelegate的appDidFinishLoading方法负载使用URL值,检查一个应用程序,我理应店在NSUserDefaults的设置根的plist:NSUserDefaults的设置包的plist
NSString *pathStr = [[NSBundle mainBundle] bundlePath];
NSString *settingsBundlePath = [pathStr stringByAppendingPathComponent:@"Settings.bundle"];
NSString *finalPath = [settingsBundlePath stringByAppendingPathComponent:@"Root.plist"];
NSDictionary *settingsDict = [NSDictionary dictionaryWithContentsOfFile:finalPath];
NSArray *prefSpecifierArray = [settingsDict objectForKey:@"PreferenceSpecifiers"];
NSDictionary *prefItem;
for (prefItem in prefSpecifierArray){
NSString *keyValueStr = [prefItem objectForKey:@"Key"];
if ([keyValueStr isEqualToString:kFirstNameKey]){
nsUserDefURL = [prefItem objectForKey:@"DefaultValue"];
}
if ([keyValueStr isEqualToString:kSecondNameKey]){
NSLog(@"You are using local data:%@",[prefItem objectForKey:@"DefaultValue"]);
}
}
NSLog(@" this is the url == %@", nsUserDefURL);
// since no default values have been set (i.e. no preferences file created), create it here
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:nsUserDefURL,kFirstNameKey,@"YES",kSecondNameKey,nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
[[NSUserDefaults standardUserDefaults] synchronize];
一些静:
NSString *kFirstNameKey = @"url";
NSString *kSecondNameKey = @"Web DataSource";
当我NSLog的nsUserDefURL,我仍然得到设置plist默认值。我进入应用程序的设置(不知道我可以在模拟器中这样做),然后我修改了url字段中的值,但是我仍然得到test2.xml值,它是设置根目录中的默认占位符值plist中。
这里是plist中:
或者它是设置包不会在Xcode的模拟器工作?