diff --git a/MacCacheCleaner/VersionHandler.swift b/MacCacheCleaner/VersionHandler.swift index 1fa9e36..9d64601 100644 --- a/MacCacheCleaner/VersionHandler.swift +++ b/MacCacheCleaner/VersionHandler.swift @@ -28,22 +28,24 @@ struct VersionHandler { let current = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String if version != current { Log.info("Latest Version = \(version) current = \(current)") - DispatchQueue.main.async { - let alert = NSAlert() - alert.alertStyle = .warning + DispatchQueue.main.async(execute: self.showAlert) + } + } + } - alert.addButton(withTitle: "Close") - alert.addButton(withTitle: "Download") + private func showAlert() { + let alert = NSAlert() + alert.alertStyle = .warning - alert.messageText = "New version \(version) available!!" - alert.informativeText = "Please update your app for latest features & bug fixes" - let response = alert.runModal() + alert.addButton(withTitle: "Close") + alert.addButton(withTitle: "Download") - if response == .alertSecondButtonReturn { - NSWorkspace.shared.open("https://github.com/kaunteya/MacCacheCleaner") - } - } - } + alert.messageText = "New version available!!" + alert.informativeText = "Please update your app for latest features & bug fixes" + let response = alert.runModal() + + if response == .alertSecondButtonReturn { + NSWorkspace.shared.open("https://github.com/kaunteya/MacCacheCleaner") } } }