DEV Community

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

Posted on

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

<- For Day 12 go here

πŸ“… 01/13/2019
πŸš€ 17 days until launch
πŸ”₯ 12 day streak
πŸ’° $4.99 price (this keeps changing)
πŸ€‘ $0 revenue
πŸ“ˆ 0 customers
⌚️ 8.5 hours spent
πŸ’» 19 files changed, 1068 insertions(+), 170 deletions(-)
🏁 Today's goals: Generate strong passwords

10:57 AM
Finally get around to stop consuming stuff on the twitter/youtube/hacker news and start working on this thing.

11:39 AM
Took me longer than it should, but I figured out how to get an NSSlider working in conjunction with a random string function and the password field. It's a pretty cool effect for not that much work: ~50 minutes. Take a look

Here's the code I mostly copy and pasted to get it working:

    @IBOutlet weak var passwordLengthSlider: NSSlider!
    @IBOutlet weak var passwordLengthLabel: NSTextField!

    func randomString(_ length: Int) -> String {
        let values = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
        return String((0...length-1).map{ _ in values.randomElement()! })
    }

    @IBAction func passwordLengthChanged(_ sender: NSSlider) {
        let passwordLength = passwordLengthSlider.integerValue
        let password = randomString(passwordLength)
        passwordLengthLabel.stringValue = "\(passwordLength)"
        passwordTextField.stringValue = password
    }

An app dev's job is kind of like a DJ or if you want to get classy, a composer. You do have to do things yourself and come up with bits of originality here or there, but it's mostly remixing and a lot of trial and error. Also the thing that took me the longest is in the xib (or storyboard or whatever apple's calling it this year) you have to check "Continuous mode"

I went searching around for a longer than I care to admit and then finally just decided to start trying random things and that was the thing that worked. I should keep going but I've got other things to do today. I might be back later, but I'll definitely be back tomorrow morning, 6 AM mountain time… hopefully.

Top comments (0)