Skip to content

Instantly share code, notes, and snippets.

@petoye
Created December 3, 2016 04:22
Show Gist options
  • Save petoye/39b182363bbfefc0916b8b407ce9815c to your computer and use it in GitHub Desktop.
Save petoye/39b182363bbfefc0916b8b407ce9815c to your computer and use it in GitHub Desktop.
Create a Notification Name:
extension Notification.Name {
static let reload = Notification.Name("reload")
}
You can post a notification
NotificationCenter.default.post(name: .reload, object: nil)
And add an observer at the view controller that you want to reload the data:
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(reloadTableData(_:)), name: .reload, object: nil)
}
func reloadTableData(_ notification: Notification) {
tableView.reloadData()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment