Skip to content

Commit

Permalink
fixed crash of application when UserDefaults data does not exist at i…
Browse files Browse the repository at this point in the history
…nitial startup
  • Loading branch information
zaru committed Dec 2, 2016
1 parent 90b71f7 commit 43b4350
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LightningQR/AppDelegate.swift
Expand Up @@ -18,7 +18,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, Validator {
var changeCount: Int = 0

func applicationDidFinishLaunching(_ aNotification: Notification) {

addingToLoginItems()

if let button = statusItem.button {
Expand Down
9 changes: 6 additions & 3 deletions LightningQR/QrcodeViewController.swift
Expand Up @@ -17,9 +17,12 @@ class QrcodeViewController: NSViewController {

override func viewDidAppear() {
let ud = UserDefaults.standard
let url:String = ud.object(forKey: "url") as! String!
let qrcode = Qrcode().generateQR(url: url)
imgQrcode.image = qrcode

let url = ud.object(forKey: "url")
if (url != nil) {
let qrcode = Qrcode().generateQR(url: url as! String)
imgQrcode.image = qrcode
}
}

@IBAction func terminate(_ sender: NSButton) {
Expand Down

0 comments on commit 43b4350

Please sign in to comment.