Day 19: Swift macOS password manager for people who hate the cloud
Tags: macos, swift, passwordmanager, cloud
Published: 2019-01-19 22:40:36

---
title: Day 19: Swift macOS password manager for people who hate the cloud
published: true
description: Follow along as I make a 100% cloudless and 100% native password manager for macOS. That's 200% raw password managing power.
tags: macos, swift, password manager, cloud
series: Making a swift MacOS password manager for people who hate the cloud
cover_image: https://thepracticaldev.s3.amazonaws.com/i/q6r73zbfbm3mpfs98bu5.jpg
---

[<- For Day 18 go here](https://dev.to/swlkr/day-18-swift-macos-password-manager-for-people-who-hate-the-cloud-550g)

📅 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](https://thepracticaldev.s3.amazonaws.com/i/obkg999g7hhzlra8bnrr.gif)

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

```swift
        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()
        }
    }
```

and then call the tableView refresh function like this

```swift
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTableView"), object: nil)
```

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 😬