DEV Community

Cover image for Day 19: Swift macOS password manager for people who hate the cloud
Sean Walker
Sean Walker

Posted on

Day 19: Swift macOS password manager for people who hate the cloud

<- For Day 18 go here

πŸ“… 01/19/2019
πŸš€ 11 days until launch
πŸ”₯ 18 day streak
πŸ’° $2.99 price (into cup of coffee territory now)
πŸ€‘ $0 revenue
πŸ“ˆ 0 customers
⌚️ 26 hours spent
πŸ’» 78 files changed, 247089 insertions(+), 54 deletions(-)
🏁 Today's goal: Adding new passwords

10:22 AM
A late start to the morning, but early enough to get some work done. Let's add adding passwords back in. Say that three times fast.

3:35 PM
A lot of progress was made, if I was on a team on this project, high fives all around. Add five more hours to the scoreboard. Anyway, got most of the functionality back at this point, along with an empty view! Here's how it's shaping up

gif is too long to show

Who said rewrites don't work?! Don't even care about that guy. Rewrite until you get it right, I say.The more rewrites closer to a deadline, the more you can look back and think yeah, I'm a baus.

Anyway, gotta take a break because 5 hours is a long time and it is Saturday after all.

Here's some code I added around refreshing the table view

        NotificationCenter.default.addObserver(self, selector: #selector(reloadTableView), name: NSNotification.Name(rawValue: "reloadTableView"), object: nil)

   @objc func reloadTableView() {
        rows = Array((try! db?.prepare(login.table))!)
        filteredRows = rows
        tableView.reloadData()

        if (filteredRows?.count)! > 0 {
            tableView.selectRowIndexes(NSIndexSet(index: 0) as IndexSet, byExtendingSelection: false)
            containerViewController?.row = rows?[0]
            containerViewController?.tableViewController = self
            containerViewController?.showDetailViewController()
        } else {
            containerViewController?.tableViewController = self
            containerViewController?.showEmptyViewController()
        }
    }
Enter fullscreen mode Exit fullscreen mode

and then call the tableView refresh function like this

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTableView"), object: nil)
Enter fullscreen mode Exit fullscreen mode

What's funny is I was trying to pass the reference to the tableViewController down through the container view controller and it wasn't working out on a brand new initialization of the app with no passwords. Definitely much better. Now I have to delete quite a bit of code surrounding calls through the object hierarchy. Sweet.

I promise to go over the overall architecture today or tomorrow. And another summary of what I've been up to before THE BIG ONE in 11 days 😬

Top comments (0)