应用程序中的 NSUserDefaults 未更新 iPhone 设置应用程序中的视图
当我在应用程序中更改和同步值时,它们会被保存,但更改不会出现在设置应用程序中。有没有办法让它们同步,同时保持在应用程序内进行更改的能力?这是我的代码:
//I'm registering the defaults from the Settings bundle I created using David Keegan's class inside my application delegate
+ (void)initialize{
if([self class] == [VirtualVeloAppDelegate class]){
[InAppSettings registerDefaults];
}
}
//I'm accessing the values like so
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[ud boolForKey:@"_someKey"]
//I'm setting the values like so
[[NSUserDefaults standardUserDefaults] setBool:switch.isOn forKey:@"_someKey"];
//After I'm done I sync
[ud synchronize];
在 iPad 和 iPhone 上的我的应用程序中,这些值都被准确地保存和调用。但是他们没有更新“设置”应用程序。
我认为我没有找到对此的明确解释这一事实可能表明 Settings.bundle 参数只能在“设置”应用程序中修改。
When I change and synchronize value in my app, they get saved, but the changes do not appear in the settings app. Is there a way to get them synced while maintaining the ability to make changes inside the app? Here is my code:
//I'm registering the defaults from the Settings bundle I created using David Keegan's class inside my application delegate
+ (void)initialize{
if([self class] == [VirtualVeloAppDelegate class]){
[InAppSettings registerDefaults];
}
}
//I'm accessing the values like so
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[ud boolForKey:@"_someKey"]
//I'm setting the values like so
[[NSUserDefaults standardUserDefaults] setBool:switch.isOn forKey:@"_someKey"];
//After I'm done I sync
[ud synchronize];
The values are getting saved and recalled accurately in my application both on the iPad and iPhone. However they are not updating the Settings app.
I think the fact that I've found no clear cut explanation of this likely indicates Settings.bundle parameters can only be modified in the Settings app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,如果您从应用程序更新,则应更新设置。
检查您是否在“设置”应用程序中进行了修改,您的应用程序中是否获得了修改后的值?
检查您是否正确注册了默认值。
正如你所说的 iPad,我猜你一定使用的是 3.2.x beta。检查 beta 是否没有问题。
Normally the settings should be updated if you update from your app.
Check if you modify in Settings app, do you get modified value in your app?
Check if you are registering the defaults properly.
As you said iPad you must be using 3.2.x beta i guess.. Check if the beta don't have an issue.
虽然我在我的应用程序中使用了 Keegan3d 的 InAppSettings 代码并且它不起作用,但我使用了该项目的全新下载,没有任何修改并且它起作用了。因此,如果实现正确,此项目中的代码就可以工作。我不确定我哪里出错了。
Although I was using Keegan3d's InAppSettings code in my app and it wasn't working, I used a fresh download of that project without any modifications and it worked. So if implemented correctly, the code from this project works. I'm not sure where I had gone wrong.