diff --git a/TrafficSweetSpot.xcodeproj/project.pbxproj b/TrafficSweetSpot.xcodeproj/project.pbxproj
index 7cf7fba..b8c9f9b 100644
--- a/TrafficSweetSpot.xcodeproj/project.pbxproj
+++ b/TrafficSweetSpot.xcodeproj/project.pbxproj
@@ -232,16 +232,16 @@
TargetAttributes = {
FA70FCC01D3EA484008BF487 = {
CreatedOnToolsVersion = 7.3.1;
- LastSwiftMigration = 0830;
+ LastSwiftMigration = 0900;
};
FA70FCCF1D3EA484008BF487 = {
CreatedOnToolsVersion = 7.3.1;
- LastSwiftMigration = 0830;
+ LastSwiftMigration = 0900;
TestTargetID = FA70FCC01D3EA484008BF487;
};
FA70FCDA1D3EA484008BF487 = {
CreatedOnToolsVersion = 7.3.1;
- LastSwiftMigration = 0830;
+ LastSwiftMigration = 0900;
TestTargetID = FA70FCC01D3EA484008BF487;
};
};
@@ -419,7 +419,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
@@ -466,7 +466,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
@@ -484,10 +484,11 @@
);
INFOPLIST_FILE = TrafficSweetSpot/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
- MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_BUNDLE_IDENTIFIER = com.fmeyer.TrafficSweetSpot;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = Default;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -502,10 +503,11 @@
);
INFOPLIST_FILE = TrafficSweetSpot/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
- MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_BUNDLE_IDENTIFIER = com.fmeyer.TrafficSweetSpot;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = Default;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -518,7 +520,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.fmeyer.TrafficSweetSpotTests;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = Default;
+ SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TrafficSweetSpot.app/Contents/MacOS/TrafficSweetSpot";
};
name = Debug;
@@ -532,7 +535,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.fmeyer.TrafficSweetSpotTests;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = Default;
+ SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TrafficSweetSpot.app/Contents/MacOS/TrafficSweetSpot";
};
name = Release;
@@ -545,7 +549,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.fmeyer.TrafficSweetSpotUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = Default;
+ SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = TrafficSweetSpot;
};
name = Debug;
@@ -558,7 +563,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.fmeyer.TrafficSweetSpotUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = Default;
+ SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = TrafficSweetSpot;
};
name = Release;
diff --git a/TrafficSweetSpot.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/TrafficSweetSpot.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
new file mode 100644
index 0000000..0c67376
--- /dev/null
+++ b/TrafficSweetSpot.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/TrafficSweetSpot/AboutWindow.swift b/TrafficSweetSpot/AboutWindow.swift
index 2348283..de091a1 100644
--- a/TrafficSweetSpot/AboutWindow.swift
+++ b/TrafficSweetSpot/AboutWindow.swift
@@ -11,8 +11,8 @@ import Cocoa
class AboutWindow: NSWindowController {
@IBOutlet weak var versionText: NSTextField!
- override var windowNibName : String! {
- return "AboutWindow"
+ override var windowNibName : NSNib.Name? {
+ return NSNib.Name.init("AboutWindow")
}
override func windowDidLoad() {
@@ -28,7 +28,7 @@ class AboutWindow: NSWindowController {
}
@IBAction func githubClick(_ sender: AnyObject) {
- NSWorkspace.shared().open(URL(string: "https://github.com/DungFu/TrafficSweetSpot")!)
+ NSWorkspace.shared.open(URL(string: "https://github.com/DungFu/TrafficSweetSpot")!)
self.window?.close()
}
}
diff --git a/TrafficSweetSpot/Info.plist b/TrafficSweetSpot/Info.plist
index 4afa6bc..8f68d11 100644
--- a/TrafficSweetSpot/Info.plist
+++ b/TrafficSweetSpot/Info.plist
@@ -17,11 +17,11 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.2
+ 1.3
CFBundleSignature
????
CFBundleVersion
- 3
+ 4
LSMinimumSystemVersion
$(MACOSX_DEPLOYMENT_TARGET)
LSUIElement
diff --git a/TrafficSweetSpot/NSTextFieldWithKeyboard.swift b/TrafficSweetSpot/NSTextFieldWithKeyboard.swift
index aad272f..a353361 100644
--- a/TrafficSweetSpot/NSTextFieldWithKeyboard.swift
+++ b/TrafficSweetSpot/NSTextFieldWithKeyboard.swift
@@ -8,42 +8,32 @@
import Cocoa
-@objc protocol UndoActionRespondable {
- func undo(_ sender: AnyObject)
-}
-
-@objc protocol RedoActionRespondable {
- func redo(_ sender: AnyObject)
-}
-
+// Copied from https://stackoverflow.com/a/41200377/1815751
class NSTextFieldWithKeyboard: NSTextField {
- fileprivate let commandKey = NSEventModifierFlags.command.rawValue
- fileprivate let commandShiftKey = NSEventModifierFlags.command.rawValue | NSEventModifierFlags.shift.rawValue
+ private let commandKey = NSEvent.ModifierFlags.command.rawValue
+ private let commandShiftKey = NSEvent.ModifierFlags.command.rawValue | NSEvent.ModifierFlags.shift.rawValue
override func performKeyEquivalent(with event: NSEvent) -> Bool {
- if event.type == NSEventType.keyDown {
- if (event.modifierFlags.rawValue & NSEventModifierFlags.deviceIndependentFlagsMask.rawValue) == commandKey {
+ if event.type == NSEvent.EventType.keyDown {
+ if (event.modifierFlags.rawValue & NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue) == commandKey {
switch event.charactersIgnoringModifiers! {
case "x":
- // New Swift 2.2 #selector works for cut, copy, paste and select all
if NSApp.sendAction(#selector(NSText.cut(_:)), to:nil, from:self) { return true }
case "c":
if NSApp.sendAction(#selector(NSText.copy(_:)), to:nil, from:self) { return true }
case "v":
if NSApp.sendAction(#selector(NSText.paste(_:)), to:nil, from:self) { return true }
case "z":
- let undoSelector = #selector(UndoActionRespondable.undo(_:))
- if NSApp.sendAction(undoSelector, to:nil, from:self) { return true }
+ if NSApp.sendAction(Selector(("undo:")), to:nil, from:self) { return true }
case "a":
- if NSApp.sendAction(#selector(NSText.selectAll(_:)), to:nil, from:self) { return true }
+ if NSApp.sendAction(#selector(NSResponder.selectAll(_:)), to:nil, from:self) { return true }
default:
break
}
}
- else if (event.modifierFlags.rawValue & NSEventModifierFlags.deviceIndependentFlagsMask.rawValue) == commandShiftKey {
+ else if (event.modifierFlags.rawValue & NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue) == commandShiftKey {
if event.charactersIgnoringModifiers == "Z" {
- let redoSelector = #selector(RedoActionRespondable.redo(_:))
- if NSApp.sendAction(redoSelector, to:nil, from:self) { return true }
+ if NSApp.sendAction(Selector(("redo:")), to:nil, from:self) { return true }
}
}
}
diff --git a/TrafficSweetSpot/PreferencesWindow.swift b/TrafficSweetSpot/PreferencesWindow.swift
index 9a798d0..cc1a30a 100644
--- a/TrafficSweetSpot/PreferencesWindow.swift
+++ b/TrafficSweetSpot/PreferencesWindow.swift
@@ -21,8 +21,8 @@ class PreferencesWindow: NSWindowController {
var delegate: PreferencesWindowDelegate?
- override var windowNibName : String! {
- return "PreferencesWindow"
+ override var windowNibName : NSNib.Name? {
+ return NSNib.Name.init("PreferencesWindow")
}
override func windowDidLoad() {
diff --git a/TrafficSweetSpot/StatusMenuController.swift b/TrafficSweetSpot/StatusMenuController.swift
index 57ceb3c..e877de8 100644
--- a/TrafficSweetSpot/StatusMenuController.swift
+++ b/TrafficSweetSpot/StatusMenuController.swift
@@ -50,7 +50,7 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
let INTERVAL_TIME_IN_SECONDS = 300.0
let THROW_AWAY_INTERVAL_MIN = 60.0
- let statusItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength)
+ let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
let mapsAPI = MapsDistanceMatrixAPI()
let versionChecker = VersionChecker()
@@ -69,7 +69,7 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
var routesData : LineChartData!
override func awakeFromNib() {
- let icon = NSImage(named: "statusIcon")
+ let icon = NSImage(named: NSImage.Name(rawValue: "statusIcon"))
icon?.isTemplate = true // best for dark mode
statusItem.image = icon
statusItem.menu = statusMenu
@@ -82,11 +82,11 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
initChartData()
updateTravelTime()
let alarm = Timer.scheduledTimer(
- timeInterval: INTERVAL_TIME_IN_SECONDS,
- target: self,
- selector: #selector(StatusMenuController.updateTravelTime),
- userInfo: nil,
- repeats: true
+ withTimeInterval: INTERVAL_TIME_IN_SECONDS,
+ repeats: true,
+ block: { (Timer) in
+ self.updateTravelTime()
+ }
)
RunLoop.main.add(alarm, forMode: RunLoopMode.commonModes)
}
@@ -224,11 +224,11 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
checkForUpdate()
checkForUpdatesTimer?.invalidate()
checkForUpdatesTimer = Timer.scheduledTimer(
- timeInterval: CHECK_FOR_UPDATES_INTERVAL_DAYS*24.0*60.0*60.0,
- target: self,
- selector: #selector(StatusMenuController.checkForUpdate),
- userInfo: nil,
- repeats: true
+ withTimeInterval: CHECK_FOR_UPDATES_INTERVAL_DAYS*24.0*60.0*60.0,
+ repeats: true,
+ block: { (Timer) in
+ self.checkForUpdate()
+ }
)
RunLoop.main.add(checkForUpdatesTimer!, forMode: RunLoopMode.commonModes)
}
@@ -247,7 +247,7 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
}
@IBAction func quitClicked(_ sender: NSMenuItem) {
- NSApplication.shared().terminate(self)
+ NSApplication.shared.terminate(self)
}
func getTimestampString(_ timestamp: Double) -> String {
diff --git a/TrafficSweetSpot/UpdateWindow.swift b/TrafficSweetSpot/UpdateWindow.swift
index b058d7d..5024723 100644
--- a/TrafficSweetSpot/UpdateWindow.swift
+++ b/TrafficSweetSpot/UpdateWindow.swift
@@ -9,8 +9,8 @@
import Cocoa
class UpdateWindow: NSWindowController {
- override var windowNibName : String! {
- return "UpdateWindow"
+ override var windowNibName : NSNib.Name? {
+ return NSNib.Name.init("UpdateWindow")
}
override func windowDidLoad() {
@@ -22,7 +22,7 @@ class UpdateWindow: NSWindowController {
}
@IBAction func downloadButtonClick(_ sender: AnyObject) {
- NSWorkspace.shared().open(URL(string: "https://github.com/DungFu/TrafficSweetSpot/releases")!)
+ NSWorkspace.shared.open(URL(string: "https://github.com/DungFu/TrafficSweetSpot/releases")!)
self.window?.close()
}
}