From 51d0faf556e151eaefd0aa336f0422aa65042654 Mon Sep 17 00:00:00 2001 From: Charles Magahern Date: Tue, 24 Sep 2019 22:17:16 -0700 Subject: [PATCH] Convert to Swift 4.0 syntax --- XIONControlPanel.xcodeproj/project.pbxproj | 6 ++--- .../Application/AppDelegate.swift | 8 +++--- .../Controllers/MainViewController.swift | 4 +-- .../Controllers/SwitchesViewController.swift | 2 +- .../VisualizationViewController.swift | 2 +- .../AppIcon.appiconset/Contents.json | 25 +++++++++++++++++++ .../Utilities/NSErrorAdditions.swift | 2 +- XIONControlPanel/Views/WemoCellView.swift | 2 +- 8 files changed, 38 insertions(+), 13 deletions(-) diff --git a/XIONControlPanel.xcodeproj/project.pbxproj b/XIONControlPanel.xcodeproj/project.pbxproj index 0a5985a..a2551bf 100644 --- a/XIONControlPanel.xcodeproj/project.pbxproj +++ b/XIONControlPanel.xcodeproj/project.pbxproj @@ -248,7 +248,7 @@ 0C3CAEA31C3350C800B856AD = { CreatedOnToolsVersion = 7.2; DevelopmentTeam = F7W5R35V7L; - LastSwiftMigration = 0810; + LastSwiftMigration = 1010; }; }; }; @@ -428,7 +428,7 @@ PRODUCT_NAME = XION; PROVISIONING_PROFILE = ""; SWIFT_OBJC_BRIDGING_HEADER = "XIONControlPanel/SupportingFiles/XIONControlPanel-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -447,7 +447,7 @@ PRODUCT_NAME = XION; PROVISIONING_PROFILE = ""; SWIFT_OBJC_BRIDGING_HEADER = "XIONControlPanel/SupportingFiles/XIONControlPanel-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/XIONControlPanel/Application/AppDelegate.swift b/XIONControlPanel/Application/AppDelegate.swift index 28bf888..ec59306 100644 --- a/XIONControlPanel/Application/AppDelegate.swift +++ b/XIONControlPanel/Application/AppDelegate.swift @@ -14,10 +14,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate var window: UIWindow? var mainViewController: MainViewController = MainViewController() - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool + func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - application.isStatusBarHidden = true - self.window = UIWindow(frame: UIScreen.main.bounds) self.window?.rootViewController = self.mainViewController self.window?.makeKeyAndVisible() @@ -35,7 +34,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate self.mainViewController.viewDidDisappear(false) } - func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask + func application(_ application: UIApplication, + supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { var mask: UIInterfaceOrientationMask = .portrait diff --git a/XIONControlPanel/Controllers/MainViewController.swift b/XIONControlPanel/Controllers/MainViewController.swift index 8e39103..02b37e3 100644 --- a/XIONControlPanel/Controllers/MainViewController.swift +++ b/XIONControlPanel/Controllers/MainViewController.swift @@ -37,11 +37,11 @@ class MainViewController: UIViewController, SwitchesViewControllerDelegate self.view.backgroundColor = UIColor.black - self.addChildViewController(_visualizationController) + self.addChild(_visualizationController) self.view.addSubview(_visualizationController.view) _switchesController.delegate = self - self.addChildViewController(_switchesController) + self.addChild(_switchesController) self.view.addSubview(_switchesController.view) self.view.addSubview(_headerView) diff --git a/XIONControlPanel/Controllers/SwitchesViewController.swift b/XIONControlPanel/Controllers/SwitchesViewController.swift index 00295ae..954b7df 100644 --- a/XIONControlPanel/Controllers/SwitchesViewController.swift +++ b/XIONControlPanel/Controllers/SwitchesViewController.swift @@ -213,7 +213,7 @@ class SwitchesViewController: UIViewController, for i in ActionCell.count ..< collectionView.numberOfItems(inSection: indexPath.section) { if let cell = collectionView.cellForItem(at: IndexPath(item: i, section: indexPath.section)) as? WemoDeviceCellView { - let animOptions = UIViewAnimationOptions([.allowUserInteraction]) + let animOptions = UIView.AnimationOptions([.allowUserInteraction]) UIView.animate(withDuration: 0.3, delay: currentDelay, options: animOptions, animations: { cell.toggled = (tappedActionCell == .allOn) diff --git a/XIONControlPanel/Controllers/VisualizationViewController.swift b/XIONControlPanel/Controllers/VisualizationViewController.swift index 457595f..d478c56 100644 --- a/XIONControlPanel/Controllers/VisualizationViewController.swift +++ b/XIONControlPanel/Controllers/VisualizationViewController.swift @@ -179,7 +179,7 @@ class VisualizationViewController: UIViewController internal func _setupModel() { - _cubletsNode.enumerateChildNodes { $0.0.removeFromParentNode() } + _cubletsNode.enumerateChildNodes { (child, _) in child.removeFromParentNode() } _cublets.removeAll() let sz = Float(VisualizationViewController.cubletsSize) diff --git a/XIONControlPanel/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json b/XIONControlPanel/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json index f542664..d4e5755 100644 --- a/XIONControlPanel/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/XIONControlPanel/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "size" : "29x29", "idiom" : "iphone", @@ -36,6 +46,16 @@ "filename" : "Icon-60@3x.png", "scale" : "3x" }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, { "size" : "29x29", "idiom" : "ipad", @@ -77,6 +97,11 @@ "idiom" : "ipad", "filename" : "Icon-167@2x.png", "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/XIONControlPanel/Utilities/NSErrorAdditions.swift b/XIONControlPanel/Utilities/NSErrorAdditions.swift index 2e98447..715d564 100644 --- a/XIONControlPanel/Utilities/NSErrorAdditions.swift +++ b/XIONControlPanel/Utilities/NSErrorAdditions.swift @@ -46,7 +46,7 @@ extension NSError class func xionError(_ code: XIONErrorCode, userInfo: [AnyHashable: Any]?) -> NSError { - return NSError(domain: XIONErrorDomain, code: code.rawValue, userInfo: userInfo) + return NSError(domain: XIONErrorDomain, code: code.rawValue, userInfo: userInfo as? [String : Any]) } var xionErrorCode: XIONErrorCode diff --git a/XIONControlPanel/Views/WemoCellView.swift b/XIONControlPanel/Views/WemoCellView.swift index dac03f8..e476c8f 100644 --- a/XIONControlPanel/Views/WemoCellView.swift +++ b/XIONControlPanel/Views/WemoCellView.swift @@ -46,7 +46,7 @@ open class WemoCellView: UICollectionViewCell if (self.isHighlighted) { _selectionOverlayView.backgroundColor = UIColor(white: 0.8, alpha: 1.0) } else { - let animOptions = UIViewAnimationOptions([.allowUserInteraction]) + let animOptions = UIView.AnimationOptions([.allowUserInteraction]) UIView.animate(withDuration: 1.0, delay: 0.0, options: animOptions, animations: { self._selectionOverlayView.backgroundColor = UIColor.clear }, completion: nil)