From 628ae11e3546bd874604541bf339922064e56347 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Thu, 2 Mar 2017 15:58:26 +0800 Subject: [PATCH] Extract adding notification observer functions into one method --- pass/Controllers/PasswordsViewController.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index d86aebb..e503f6f 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -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