add erase data function

This commit is contained in:
Bob Sun 2017-02-07 16:45:14 +08:00
parent 373c6500f0
commit e2a2774664
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
6 changed files with 173 additions and 12 deletions

View file

@ -55,6 +55,8 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
super.viewDidLoad()
passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData()
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)
generateSections(item: passwordEntities!)
tableView.delegate = self
tableView.dataSource = self
@ -160,6 +162,13 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
print("actOnPasswordUpdatedNotification")
}
func actOnPasswordStoreErasedNotification() {
passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData()
reloadTableView(data: passwordEntities!)
print("actOnPasswordErasedNotification")
}
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
if identifier == "showPasswordDetail" {
if Defaults[.pgpKeyID] == "" {