My question is how to update or reload ViewController when cell selected in UITableView. I have ViewController with two buttons and when you click on one of them you will go to tableViewController and when you select one option, the option will be saved by
NSUserDefaults.standardUserDefaults()
and tableViewController will dismiss by
self.dismissViewControllerAnimated(true, completion: nil)
. I used
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let cell = self.tableView.cellForRowAtIndexPath(indexPath)
let lang_name = cell!.textLabel!.text!
NSUserDefaults.standardUserDefaults().setObject(lang_name,forKey:"lang_saved")
NSUserDefaults.standardUserDefaults().synchronize()
self.dismissViewControllerAnimated(true, completion: nil)
}
and
super.viewDidLoad()
if let lang_saved = NSUserDefaults.standardUserDefaults().objectForKey("lang_saved") {
button1.setTitle("\(lang_saved)", forState: .Normal)
}
My problem is I must restart my app to get right result, I mean that the viewcontroller must be reloaded to get button name from
NSUserDefaults.standardUserDefaults()
how can I solve that?