1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-11 09:28:38 +00:00

update swift to 5.0

This commit is contained in:
Serg 2019-10-17 23:23:24 +07:00
parent 92975cb8e4
commit e68fa10c42
5 changed files with 17 additions and 15 deletions

View File

@ -362,7 +362,7 @@
TargetAttributes = { TargetAttributes = {
B082B24E205C7D8000BC04DC = { B082B24E205C7D8000BC04DC = {
CreatedOnToolsVersion = 9.2; CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1000; LastSwiftMigration = 1020;
ProvisioningStyle = Manual; ProvisioningStyle = Manual;
SystemCapabilities = { SystemCapabilities = {
com.apple.Sandbox = { com.apple.Sandbox = {
@ -372,7 +372,7 @@
}; };
B082B260205C7D8000BC04DC = { B082B260205C7D8000BC04DC = {
CreatedOnToolsVersion = 9.2; CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1000; LastSwiftMigration = 1020;
}; };
}; };
}; };
@ -640,7 +640,7 @@
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "MTMR/CBridge/TouchBarPrivateApi-Bridging.h"; SWIFT_OBJC_BRIDGING_HEADER = "MTMR/CBridge/TouchBarPrivateApi-Bridging.h";
SWIFT_VERSION = 4.2; SWIFT_VERSION = 5.0;
}; };
name = Debug; name = Debug;
}; };
@ -663,7 +663,7 @@
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "MTMR/CBridge/TouchBarPrivateApi-Bridging.h"; SWIFT_OBJC_BRIDGING_HEADER = "MTMR/CBridge/TouchBarPrivateApi-Bridging.h";
SWIFT_VERSION = 4.2; SWIFT_VERSION = 5.0;
}; };
name = Release; name = Release;
}; };
@ -676,7 +676,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMRTests; PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMRTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2; SWIFT_VERSION = 5.0;
}; };
name = Debug; name = Debug;
}; };
@ -691,7 +691,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMRTests; PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMRTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2; SWIFT_VERSION = 5.0;
}; };
name = Release; name = Release;
}; };

View File

@ -56,7 +56,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
} }
if frontmostApplicationIdentifier != nil { if frontmostApplicationIdentifier != nil {
isBlockedApp = blacklistAppIdentifiers.index(of: frontmostApplicationIdentifier!) != nil isBlockedApp = blacklistAppIdentifiers.firstIndex(of: frontmostApplicationIdentifier!) != nil
} else { } else {
isBlockedApp = false isBlockedApp = false
} }
@ -81,7 +81,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@objc func toggleBlackListedApp(_: Any?) { @objc func toggleBlackListedApp(_: Any?) {
let appIdentifier = TouchBarController.shared.frontmostApplicationIdentifier let appIdentifier = TouchBarController.shared.frontmostApplicationIdentifier
if appIdentifier != nil { if appIdentifier != nil {
if let index = TouchBarController.shared.blacklistAppIdentifiers.index(of: appIdentifier!) { if let index = TouchBarController.shared.blacklistAppIdentifiers.firstIndex(of: appIdentifier!) {
TouchBarController.shared.blacklistAppIdentifiers.remove(at: index) TouchBarController.shared.blacklistAppIdentifiers.remove(at: index)
} else { } else {
TouchBarController.shared.blacklistAppIdentifiers.append(appIdentifier!) TouchBarController.shared.blacklistAppIdentifiers.append(appIdentifier!)

View File

@ -161,7 +161,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
} }
func updateActiveApp() { func updateActiveApp() {
if frontmostApplicationIdentifier != nil && blacklistAppIdentifiers.index(of: frontmostApplicationIdentifier!) != nil { if frontmostApplicationIdentifier != nil && blacklistAppIdentifiers.firstIndex(of: frontmostApplicationIdentifier!) != nil {
dismissTouchBar() dismissTouchBar()
} else { } else {
presentTouchBar() presentTouchBar()

View File

@ -80,7 +80,7 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
func updateRunningApplication() { func updateRunningApplication() {
let newApplications = launchedApplications() let newApplications = launchedApplications()
let index = newApplications.index { let index = newApplications.firstIndex {
$0.bundleIdentifier == frontmostApplicationIdentifier $0.bundleIdentifier == frontmostApplicationIdentifier
} }
@ -202,7 +202,7 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
} }
} else { } else {
HapticFeedback.shared?.tap(strong: 6) HapticFeedback.shared?.tap(strong: 6)
if let index = self.persistentAppIdentifiers.index(of: bundleIdentifier!) { if let index = self.persistentAppIdentifiers.firstIndex(of: bundleIdentifier!) {
persistentAppIdentifiers.remove(at: index) persistentAppIdentifiers.remove(at: index)
} else { } else {
persistentAppIdentifiers.append(bundleIdentifier!) persistentAppIdentifiers.append(bundleIdentifier!)

View File

@ -31,7 +31,7 @@ class NetworkBarItem: CustomButtonTouchBarItem, Widget {
var dSpeed: UInt64? var dSpeed: UInt64?
var uSpeed: UInt64? var uSpeed: UInt64?
var curr: Array<Substring>? var curr: Array<Substring>?
var dataAvailable: NSObjectProtocol! var dataAvailable: NSObjectProtocol?
pipe = Pipe() pipe = Pipe()
bandwidthProcess = Process() bandwidthProcess = Process()
@ -64,19 +64,21 @@ class NetworkBarItem: CustomButtonTouchBarItem, Widget {
} }
} }
outputHandle.waitForDataInBackgroundAndNotify() outputHandle.waitForDataInBackgroundAndNotify()
} else { } else if let dataAvailable = dataAvailable {
NotificationCenter.default.removeObserver(dataAvailable) NotificationCenter.default.removeObserver(dataAvailable)
} }
} }
var dataReady: NSObjectProtocol! var dataReady: NSObjectProtocol?
dataReady = NotificationCenter.default.addObserver( dataReady = NotificationCenter.default.addObserver(
forName: Process.didTerminateNotification, forName: Process.didTerminateNotification,
object: outputHandle, object: outputHandle,
queue: nil queue: nil
) { _ -> Void in ) { _ -> Void in
print("Task terminated!") print("Task terminated!")
NotificationCenter.default.removeObserver(dataReady) if let observer = dataReady {
NotificationCenter.default.removeObserver(observer)
}
} }
bandwidthProcess?.launch() bandwidthProcess?.launch()