From 9a7c16cab859e30257f0c935a994082aded7c17e Mon Sep 17 00:00:00 2001 From: Ty Cobb Date: Tue, 10 May 2016 14:59:17 -0500 Subject: [PATCH] fix helper indentation --- HarborHelper/HarborHelper/AppDelegate.swift | 58 ++++++++++----------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/HarborHelper/HarborHelper/AppDelegate.swift b/HarborHelper/HarborHelper/AppDelegate.swift index 57ff150..e9fed02 100644 --- a/HarborHelper/HarborHelper/AppDelegate.swift +++ b/HarborHelper/HarborHelper/AppDelegate.swift @@ -10,39 +10,35 @@ import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { - - func applicationDidFinishLaunching(aNotification: NSNotification) { - let app = NSWorkspace.sharedWorkspace().runningApplications.find { app in - return app.bundleIdentifier == "com.dvm.Harbor" - } - - // if the app isn't running, then let's start it - if app == nil || !app!.active { - let path = self.applicationPath() - NSWorkspace.sharedWorkspace().launchApplication(path) - } - - // kill the helper app - NSApp.terminate(nil) + func applicationDidFinishLaunching(aNotification: NSNotification) { + let app = NSWorkspace.sharedWorkspace().runningApplications.find { app in + return app.bundleIdentifier == "com.dvm.Harbor" } - - private func applicationPath() -> String { - var components = NSBundle.mainBundle().bundlePath.componentsSeparatedByString("/") - - // helper is at "Library/LoginItems/HarborHelper" relative to the app root - components.removeRange(components.count-3.. String { + var components = NSBundle.mainBundle().bundlePath.componentsSeparatedByString("/") + + // helper is at "Library/LoginItems/HarborHelper" relative to the app root + components.removeRange(components.count-3.. Bool) -> Generator.Element? { - return self.filter(predicate).first - } - -} \ No newline at end of file + func find(predicate: (Generator.Element) -> Bool) -> Generator.Element? { + return self.filter(predicate).first + } +}