I have just been implementing the InAppSettingsKit for my app and now I'm trying to determine the best way to push out the new settings to my app. At present I have a couple of different view controllers that will be effected by setting changes. I understand that I will need to use a delegate method, however I would like some advice on how best to update other view controllers with new settings. Is there some sort of best practice that should be followed?
我刚刚为我的应用程序实现了InAppSettingsKit,现在我正在尝试确定将新设置推送到我的应用程序的最佳方法。目前,我有几个不同的视图控制器,将通过设置更改来实现。我知道我需要使用委托方法,但是我想知道如何最好地使用新设置更新其他视图控制器。是否应该遵循某种最佳做法?
1 个解决方案
#1
1
I believe that inAppSettingsKit uses NSUserDefaults
, in which case the same practices apply.
我相信inAppSettingsKit使用NSUserDefaults,在这种情况下适用相同的做法。
General good practice for changed settings is to observe the notification NSUserDefaultsDidChangeNotification
and update your views in the observer method. As many observers are usually required, delegate methods aren't a good solution for this problem.
更改设置的一般良好做法是观察NSUserDefaultsDidChangeNotification通知并在observer方法中更新您的视图。由于通常需要许多观察者,委托方法不是解决此问题的好方法。
#1
1
I believe that inAppSettingsKit uses NSUserDefaults
, in which case the same practices apply.
我相信inAppSettingsKit使用NSUserDefaults,在这种情况下适用相同的做法。
General good practice for changed settings is to observe the notification NSUserDefaultsDidChangeNotification
and update your views in the observer method. As many observers are usually required, delegate methods aren't a good solution for this problem.
更改设置的一般良好做法是观察NSUserDefaultsDidChangeNotification通知并在observer方法中更新您的视图。由于通常需要许多观察者,委托方法不是解决此问题的好方法。