DEV Community

Cover image for Day 5: Making a swift macOS password manager for people who hate the cloud

Day 5: Making a swift macOS password manager for people who hate the cloud

Sean Walker
Takes hikes 🏔 Makes sites 👨‍💻
Originally published at ・2 min read

<- For Day 4 go here

Living life

I know it might seem like a daily streak thing is a bad idea, I mean, what happens when you actually live your life instead of code all day? What happens then? Today, I went snowboarding with some friends who flew into town and I had a great time! I only fell a few times and amazed myself! I'm not an expert snowboarder by any means, or even a good one, so that was cool.

The streak must continue

Look, I've been writing every day for 34 days, and coding this product for 4 days, I can't break the streak just because I lived my life today! The streak goes on. There's only 30 minutes until I pass out from exhaustion, so let's see what I can whip up. Turns out, not much. I did manage to slap labels and text fields on the view though, so that's something. I messed around with tucking the sqlite code away behind a struct, I might try something where inheritance or protocols is involved, so I wind up with something similar to active record, here's where I left off:

import SQLite

struct Login {
    let id = Expression<Int64>("id")
    let username = Expression<String?>("username")
    let email = Expression<String>("email")
    let key = Expression<String>("key")
    var db: Connection

    static func database() -> Connection {
        let path = NSSearchPathForDirectoriesInDomains(
            .applicationSupportDirectory, .userDomainMask, true
            ).first! + "/" + Bundle.main.bundleIdentifier!

        do {
            try FileManager.default.createDirectory(
                atPath: path, withIntermediateDirectories: true, attributes: nil
        } catch {
            print("Unexpected error: \(error).")

        var conn : Connection?
        do {
            conn = try Connection("\(path)/app.db")
        } catch {
            print("Unexpected error: \(error).")

        return conn!

    init() {
        db = Login.database()

Tune in tomorrow for Day 6 🔥

Discussion (0)