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

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

swlkr profile image Sean Walker Originally published at streaking.app ・3 min read

Making a swift MacOS password manager for people who hate the cloud (32 Part Series)

1) Day 1: Making a swift macOS password manager for people who hate the cloud 2) Day 2: Making a swift macOS password manager for people who hate the cloud 3 ... 30 3) Day 3: Making a swift macOS password manager for people who hate the cloud 4) Day 4: Making a swift macOS password manager for people who hate the cloud 5) Day 5: Making a swift macOS password manager for people who hate the cloud 6) Day 6: Making a swift macOS password manager for people who hate the cloud 7) Day 7: Making a swift macOS password manager for people who hate the cloud 8) Day 8: Making a swift MacOS password manager for people who hate the cloud 9) Day 9: Making a swift macOS password manager for people who hate the cloud 10) Day 10: Making a swift macOS password manager for people who hate the cloud 11) Day 11: Making a swift macOS password manager for people who hate the cloud 12) Day 12: Swift macOS password manager for people who hate the cloud 13) Day 13: Swift macOS password manager for people who hate the cloud 14) Day 14: Swift macOS password manager for people who hate the cloud 15) Day 15: Swift macOS password manager for people who hate the cloud 16) Day 16: Swift macOS password manager for people who hate the cloud 17) Day 17: Swift macOS password manager for people who hate the cloud 18) Day 18: Swift macOS password manager for people who hate the cloud 19) Day 19: Swift macOS password manager for people who hate the cloud 20) Day 20: Swift macOS password manager for people who hate the cloud 21) Day 21: Swift macOS password manager for people who hate the cloud 22) Day 22: Swift macOS password manager for people who hate the cloud 23) Day 23: Swift macOS password manager for people who hate the cloud 24) Day 24: Swift macOS password manager for people who hate the cloud 25) Day 25: Swift macOS password manager for people who hate the cloud 26) Day 26: Swift macOS password manager for people who hate the cloud 27) Day 27: Swift macOS password manager for people who hate the cloud 28) Day 28: Swift macOS password manager for people who hate the cloud 29) Day 29: Swift macOS password manager for people who hate the cloud 30) Day 30: Swift macOS password manager for people who hate the cloud 31) Day 31: Swift macOS password manager for people who hate the cloud 32) How did my password manager do after launch?

<- For Day 3 go here

I got super sidetracked today and there's an hour left until midnight, BUT I'm determined to keep the streak alive! So this is what I did today, I moved the tableview over and I decided to completely rip 1password off with it's weird ios/macos hybrid app. So here's what the table view looks like, it's one column, as the late great steve jobs has let us know is really the only way to make tableviews

So that actually looks really fricken good, only took a few constraints in storyboard to make it too. I'm actually starting to like macos development, I'm starting to see how backwards CSS is. In short. I'm a fan now compared to a few days ago, or maybe that's just the stockholm syndrome working it's swedish magic? Anyway, so that looks good, unfortunately, still no passwords in there, so here's what I wanted to do Cmd+N or File->New to make a new password with a new view to the right of it. Boy, I didn't know what I was in for. I start to click around my storyboard and voila

you can actually select the little fake menu there, and you can select File->New, so my next thought was let me drag this to the view controller, but no that doesn't work. I'm starting to get envious of web developers again, and of course I immediately google up a solution. You have to control + drag your mouse 🐁 TWO TIMES. First from New to the AppDelegate.swift file like so

In this gif I had already done it and wired it to addNewLogin, but there it is, you make up a func and you're almost home. Then from there you control+drag from New to that little orange box next to the two blue boxes and you select the name of the function YOU JUST MADE. Now the third and final step is to... and I 💩 you not, COPY AND PASTE the function definition from AppDelegate.swift to the view controller DOT swift file of your choice.

At this point, I'm so many WTFs deep and so pressed for time that I'm just happy the thing is firing at all. But I still have an hour and both of my daily goals are about to be met (daily blog and daily progress toward this password manager), so I press on. I get as far as showing the "add password" view controller and then that's it, time's up. So here's what I wound up with in terms of code:

    @IBAction func addNewLogin(_ sender: NSMenuItem) {

        let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: Bundle.main)
        let viewController = storyboard.instantiateController(withIdentifier: "AddLoginViewController") as! NSViewController

        for sView in self.containerView.subviews {
            sView.removeFromSuperview()
        }

        viewController.view.frame = containerView.bounds
        containerView.addSubview(viewController.view)
    }

Oh! That's hot... that's hot. Barely any code today!

Kids, don't drink and program. Day 5 coming soon (as in tomorrow)

Making a swift MacOS password manager for people who hate the cloud (32 Part Series)

1) Day 1: Making a swift macOS password manager for people who hate the cloud 2) Day 2: Making a swift macOS password manager for people who hate the cloud 3 ... 30 3) Day 3: Making a swift macOS password manager for people who hate the cloud 4) Day 4: Making a swift macOS password manager for people who hate the cloud 5) Day 5: Making a swift macOS password manager for people who hate the cloud 6) Day 6: Making a swift macOS password manager for people who hate the cloud 7) Day 7: Making a swift macOS password manager for people who hate the cloud 8) Day 8: Making a swift MacOS password manager for people who hate the cloud 9) Day 9: Making a swift macOS password manager for people who hate the cloud 10) Day 10: Making a swift macOS password manager for people who hate the cloud 11) Day 11: Making a swift macOS password manager for people who hate the cloud 12) Day 12: Swift macOS password manager for people who hate the cloud 13) Day 13: Swift macOS password manager for people who hate the cloud 14) Day 14: Swift macOS password manager for people who hate the cloud 15) Day 15: Swift macOS password manager for people who hate the cloud 16) Day 16: Swift macOS password manager for people who hate the cloud 17) Day 17: Swift macOS password manager for people who hate the cloud 18) Day 18: Swift macOS password manager for people who hate the cloud 19) Day 19: Swift macOS password manager for people who hate the cloud 20) Day 20: Swift macOS password manager for people who hate the cloud 21) Day 21: Swift macOS password manager for people who hate the cloud 22) Day 22: Swift macOS password manager for people who hate the cloud 23) Day 23: Swift macOS password manager for people who hate the cloud 24) Day 24: Swift macOS password manager for people who hate the cloud 25) Day 25: Swift macOS password manager for people who hate the cloud 26) Day 26: Swift macOS password manager for people who hate the cloud 27) Day 27: Swift macOS password manager for people who hate the cloud 28) Day 28: Swift macOS password manager for people who hate the cloud 29) Day 29: Swift macOS password manager for people who hate the cloud 30) Day 30: Swift macOS password manager for people who hate the cloud 31) Day 31: Swift macOS password manager for people who hate the cloud 32) How did my password manager do after launch?

Posted on Jan 5 '19 by:

swlkr profile

Sean Walker

@swlkr

Takes hikes 🏔 Makes sites 👨‍💻

Discussion

markdown guide
 

Great project! I also rediscovered Swift and Cocoa after some time with Electron. I don't know why, but it feels so much better to work on a native app. I also started to do hackingwithswift.com/store/hacking... and it's great at explaining the whole ViewControllerDelegateResponder-Hell.

 

Yeah, Delegate Responder stuff really takes some getting used to, but I mean it kind of makes sense now in a crazy way