Extract adding notification observer functions into one method

This commit is contained in:
Bob Sun 2017-03-02 15:58:26 +08:00
parent c79624caf0
commit 628ae11e35
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4

View file

@ -120,13 +120,17 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
}
}
private func addNotificationObservers() {
NotificationCenter.default.addObserver(self, selector: #selector(PasswordsViewController.actOnPasswordUpdatedNotification), name: NSNotification.Name(rawValue: "passwordUpdated"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(PasswordsViewController.actOnPasswordStoreErasedNotification), name: NSNotification.Name(rawValue: "passwordStoreErased"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(PasswordsViewController.actOnSearchNotification), name: NSNotification.Name(rawValue: "search"), object: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
setNavigationItemTitle()
initPasswordsTableEntries()
NotificationCenter.default.addObserver(self, selector: #selector(PasswordsViewController.actOnPasswordUpdatedNotification), name: NSNotification.Name(rawValue: "passwordUpdated"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(PasswordsViewController.actOnPasswordStoreErasedNotification), name: NSNotification.Name(rawValue: "passwordStoreErased"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(PasswordsViewController.actOnSearchNotification), name: NSNotification.Name(rawValue: "search"), object: nil)
addNotificationObservers()
generateSections(item: passwordsTableEntries)
tableView.delegate = self