NSUserDafaults reading Root.plist got a nil value

依然范特西╮ 提交于 2019-12-11 10:26:49

问题


This is the code in my AppDelegate:

    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"];

prefSpecifiersArray is setted to 0x0 < nil >. I really don't know how is it possible! This is my Root.plist:


回答1:


The values from settings.bundle do not actually load to NSUserDefaults until the user opens the settings for the first time. By default, they are off. Once the user opens the settings bundle, they will fill in for you.



来源:https://stackoverflow.com/questions/8443639/nsuserdafaults-reading-root-plist-got-a-nil-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!