如何确定iOS上的设置更改时间 [英] How to determine when Settings change on iOS

查看:135
本文介绍了如何确定iOS上的设置更改时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用iPhone的标准 root.plist 方法创建了一个自定义的Settings.app包。我想知道是否有办法确定用户何时在我的应用程序中更改这些设置...

I have created a custom Settings.app bundle using the standard root.plist approach for the iPhone. I'm wondering if there's a way to determine when the user changes those settings in my app...

推荐答案

你可以听对于NSUSerDefaultsDidChange-通知与此:

You can listen for NSUSerDefaultsDidChange-notifications with this:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(defaultsChanged) name:NSUserDefaultsDidChangeNotification object:nil];

每当NSUserDefaults发生变化时, defaultsChanged 将是叫。

Whenever the NSUserDefaults changes, defaultsChanged will be called.

别忘了拨打 [[NSNotificationCenter defaultCenter] removeObserver:self]; when你想停止监听这些通知(当对象被取消分配时你也应该这样做。)

Don't forget to call [[NSNotificationCenter defaultCenter] removeObserver:self]; when you want to stop listening for these notifications (you should also do this when object gets deallocated).

这篇关于如何确定iOS上的设置更改时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆