为什么设置默认值不显示在 iPhone 应用程序中?

发布于 2024-12-27 16:15:47 字数 218 浏览 1 评论 0原文

我使用 Root.plist 文件将默认值加载到应用程序设置中。这些值似乎加载得很好,我可以从设备上的“设置”中看到它们。

但是,应用程序本身似乎看不到这些值,它只能看到手动输入到设备中的值(通过“设置”)。

无论是默认值还是设备输入的值,在“设置”中显示的值都是相同的。我(显然)使用相同的代码来加载应用程序中的值,无论它们是默认值还是设备输入的。

有人看到我缺少什么吗?

I’m loading default values into the apps Settings using a Root.plist file. The values seem to load fine, and I can see them from Settings on the device.

However, the app itself doesn’t seem to see those values, it only sees the values that have been manually typed into the device (via Settings).

The values appear the same in Settings, whether defaults or device-entered. I use the same code (obviously) for loading the values in the app, whether they are defaults or device-entered.

Anyone see what I'm missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断念 2025-01-03 16:15:47

在 Root.plist 中设置默认值实际上非常具有误导性,它不会创建默认值。您必须使用

[NSUserDefaults standardUserDefaults] registerDefaults:aDictionaryHere];

DictionaryHere 来注册默认值,这里是一个 NSDictionary 对象,其中包含您想要注册为默认值的键和值,例如,

[NSDictionary dictionaryWithObject:@"English" forKey:@"Language"];

此键和值必须与您在 Root.plist 中设置的内容相匹配

Setting the default in Root.plist is quite misleading actually, it doesn't create default value. You have to register the defaults using

[NSUserDefaults standardUserDefaults] registerDefaults:aDictionaryHere];

aDictionaryHere is a NSDictionary object with the key and value you want to register as defaults, for example

[NSDictionary dictionaryWithObject:@"English" forKey:@"Language"];

This key and value will have to match whatever you set in your Root.plist

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文