Skip to content

Commit

Permalink
Update to Swift 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriskuei committed Nov 15, 2017
1 parent b29cba3 commit 553da56
Show file tree
Hide file tree
Showing 118 changed files with 1,288 additions and 971 deletions.
22 changes: 18 additions & 4 deletions Bon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0910;
ORGANIZATIONNAME = Chris;
TargetAttributes = {
832444E01CDF17860031CFE0 = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0830;
LastSwiftMigration = 0910;
};
};
};
Expand Down Expand Up @@ -331,14 +331,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -378,14 +384,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -423,7 +435,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.chriskuei.Bon;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -441,7 +454,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.chriskuei.Bon;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -45,6 +46,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
8 changes: 4 additions & 4 deletions Bon/BonButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Cocoa

class BonButton: NSButton {

fileprivate let cursor = NSCursor.pointingHand()
fileprivate let cursor = NSCursor.pointingHand
fileprivate var normalStateImage: NSImage?
fileprivate var highlightedStateImage: NSImage?
fileprivate var trackingArea: NSTrackingArea?
Expand Down Expand Up @@ -41,8 +41,8 @@ class BonButton: NSButton {
func setImages(_ normalImage: String, highlitedImage: String) {
self.setButtonType(.momentaryChange)

normalStateImage = NSImage(named: normalImage)
highlightedStateImage = NSImage(named: highlitedImage)
normalStateImage = NSImage(named: NSImage.Name(rawValue: normalImage))
highlightedStateImage = NSImage(named: NSImage.Name(rawValue: highlitedImage))
}

func resetTrackingArea() {
Expand All @@ -55,7 +55,7 @@ class BonButton: NSButton {

fileprivate func createTrackingAreaIfNeeded() {
if trackingArea == nil {
trackingArea = NSTrackingArea(rect: CGRect.zero, options: [.inVisibleRect, .mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil)
trackingArea = NSTrackingArea(rect: CGRect.zero, options: [NSTrackingArea.Options.inVisibleRect, NSTrackingArea.Options.mouseEnteredAndExited, NSTrackingArea.Options.activeAlways], owner: self, userInfo: nil)
}
}

Expand Down
6 changes: 3 additions & 3 deletions Bon/BonCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BonCell: NSTableCellView {

fileprivate var item: BonItem?

fileprivate let cursor = NSCursor.pointingHand()
fileprivate let cursor = NSCursor.pointingHand
fileprivate var trackingArea: NSTrackingArea?
fileprivate var mouseInside = false {
didSet {
Expand All @@ -28,7 +28,7 @@ class BonCell: NSTableCellView {
}

class func view(_ tableView: NSTableView, owner: AnyObject?, subject: AnyObject?) -> NSView {
let view = tableView.make(withIdentifier: "BonCell", owner: owner) as! BonCell
let view = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "BonCell"), owner: owner) as! BonCell

if let item = subject as? BonItem {
view.setItem(item)
Expand Down Expand Up @@ -91,7 +91,7 @@ class BonCell: NSTableCellView {

fileprivate func createTrackingAreaIfNeeded() {
if trackingArea == nil {
trackingArea = NSTrackingArea(rect: CGRect.zero, options: [NSTrackingAreaOptions.inVisibleRect, NSTrackingAreaOptions.mouseEnteredAndExited, NSTrackingAreaOptions.activeAlways], owner: self, userInfo: nil)
trackingArea = NSTrackingArea(rect: CGRect.zero, options: [NSTrackingArea.Options.inVisibleRect, NSTrackingArea.Options.mouseEnteredAndExited, NSTrackingArea.Options.activeAlways], owner: self, userInfo: nil)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Bon/BonNetwork.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ class BonNetwork: NSObject {
success(value)

case .failure(let error):
fail(error: error)
fail(error)
}
}


}


static func logout() {
@objc static func logout() {

let parameters = [
"action": "auto_logout"
Expand Down
6 changes: 3 additions & 3 deletions Bon/BonTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class BonTextField: NSTextField {
extension BonTextField {

override func performKeyEquivalent(with event: NSEvent) -> Bool {
if event.type == NSEventType.keyDown {
if (event.modifierFlags.rawValue & NSEventModifierFlags.deviceIndependentFlagsMask.rawValue) == NSEventModifierFlags.command.rawValue {
if event.type == NSEvent.EventType.keyDown {
if (event.modifierFlags.rawValue & NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue) == NSEvent.ModifierFlags.command.rawValue {
switch event.charactersIgnoringModifiers! {
case "x":
if NSApp.sendAction(#selector(NSText.cut(_:)), to:nil, from:self) { return true }
Expand All @@ -32,7 +32,7 @@ extension BonTextField {
break
}
}
else if (event.modifierFlags.rawValue & NSEventModifierFlags.deviceIndependentFlagsMask.rawValue) == NSEventModifierFlags.command.rawValue | NSEventModifierFlags.shift.rawValue {
else if (event.modifierFlags.rawValue & NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue) == NSEvent.ModifierFlags.command.rawValue | NSEvent.ModifierFlags.shift.rawValue {
if event.charactersIgnoringModifiers == "Z" {
if NSApp.sendAction(Selector(("redo:")), to:nil, from:self) { return true }
}
Expand Down
2 changes: 1 addition & 1 deletion Bon/BonViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class BonViewController: NSViewController {

// MARK : - get online info

func getOnlineInfo() {
@objc func getOnlineInfo() {

let parameters = [
"action": "get_online_info"
Expand Down
4 changes: 2 additions & 2 deletions Bon/EventMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import Cocoa

open class EventMonitor {
fileprivate var monitor: AnyObject?
fileprivate let mask: NSEventMask
fileprivate let mask: NSEvent.EventTypeMask
fileprivate let handler: (NSEvent?) -> ()

public init(mask: NSEventMask, handler: @escaping (NSEvent?) -> ()) {
public init(mask: NSEvent.EventTypeMask, handler: @escaping (NSEvent?) -> ()) {
self.mask = mask
self.handler = handler
}
Expand Down
4 changes: 2 additions & 2 deletions Bon/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.5.1</string>
<string>0.5.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>170403</string>
<string>171115</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
Expand Down
24 changes: 12 additions & 12 deletions Bon/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
import Cocoa

class MainViewController: NSViewController {
let statusItem = NSStatusBar.system().statusItem(withLength: -2)
let statusItem = NSStatusBar.system.statusItem(withLength: -2)
let popover = NSPopover()
var eventMonitor: EventMonitor?
var refreshTimer: Timer?

override func awakeFromNib() {
if let button = statusItem.button {
let icon = NSImage(named: "icon_status")
let icon = NSImage(named: NSImage.Name(rawValue: "icon_status"))
icon?.isTemplate = false
button.image = icon
button.action = #selector(self.togglePopover(_:))
}

popover.behavior = .transient
popover.contentViewController = BonViewController(nibName: "BonViewController", bundle: nil)
popover.appearance = NSAppearance(named: NSAppearanceNameAqua)
popover.contentViewController = BonViewController(nibName: NSNib.Name(rawValue: "BonViewController"), bundle: nil)
popover.appearance = NSAppearance(named: NSAppearance.Name.aqua)
popover.behavior = .transient

eventMonitor = EventMonitor(mask: [.leftMouseDown, .rightMouseDown]) { [unowned self] event in
eventMonitor = EventMonitor(mask: [NSEvent.EventTypeMask.leftMouseDown, NSEvent.EventTypeMask.rightMouseDown]) { [unowned self] event in
if self.popover.isShown {
self.closePopover(event)
}
Expand All @@ -48,7 +48,7 @@ class MainViewController: NSViewController {

}

func togglePopover(_ sender: AnyObject?) {
@objc func togglePopover(_ sender: AnyObject?) {
if popover.isShown {
closePopover(sender)
} else {
Expand All @@ -69,20 +69,20 @@ class MainViewController: NSViewController {
eventMonitor?.stop()
}

func openGithub() {
@objc func openGithub() {
let path = "https://github.com/Chriskuei"
let url = URL(string: path)!
NSWorkspace.shared().open(url)
NSWorkspace.shared.open(url)
}

func openWeibo() {
@objc func openWeibo() {
let path = "https://weibo.com/chenjiangui"
let url = URL(string: path)!
NSWorkspace.shared().open(url)
NSWorkspace.shared.open(url)
}

func quit() {
NSApplication.shared().terminate(self)
@objc func quit() {
NSApplication.shared.terminate(self)
}

}
2 changes: 1 addition & 1 deletion Bon/SettingsMenuAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Foundation
class SettingsMenuAction {

class func makeSettingsMenu(_ sender: NSView) {
let delegate = NSApplication.shared().delegate as! MainViewController
let delegate = NSApplication.shared.delegate as! MainViewController

let menu = NSMenu()

Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "Alamofire/Alamofire" ~> 4.4
github "Alamofire/Alamofire" ~> 4.5
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "Alamofire/Alamofire" "4.4.0"
github "Alamofire/Alamofire" "4.5.1"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file modified Carthage/Build/Mac/Alamofire.framework/Versions/A/Alamofire
Binary file not shown.
Loading

0 comments on commit 553da56

Please sign in to comment.