I wrote an app which I need to reload all settings when default settings has changed.
But I don't have a clue. I tried relaunching or reloading first view controller but it wasn't working. my problem is in all view controllers I fetch from core data and load labels from it but I have to close the app and relaunch it to see the changes.
any idea how to accomplish this ?
Your core problem is reloading data after changing settings. There are many ways achieving this purpose. One is using KVO to observe settings for all the UI elements you want to change.
There is another force way to make you don't need relaunch the app.
Because all your data used after the viewControllers' init
method. Instead of reloading first viewController, renew your application's rootViewController
and set it.
After changing your settings.
if let tabBarController = UIApplication.sharedApplication().keyWindow?.rootViewController as? UITabBarViewController {
let naviController1 = UINavigationController(rootViewController: HomeViewController())
let naviController2 = UINavigationController(rootViewController: AccountViewController())
tabBarController.viewControllers = [naviController1, naviController2]
}
OR
UIApplication.sharedApplication().keyWindow?.rootViewController = YOURTabBarController()