From 86880dea149a871ec5cb909cc3b93e7fb5804788 Mon Sep 17 00:00:00 2001 From: Jandzso Zsolt Date: Sat, 23 Jun 2018 19:57:44 +0200 Subject: [PATCH] auto-correct things to swift 4.2 --- Source/ShoutFactory.swift | 4 ++-- Source/WhisperFactory.swift | 27 ++++++++++++++++++++------- Source/WhistleFactory.swift | 10 +++++----- Whisper.xcodeproj/project.pbxproj | 4 ++-- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Source/ShoutFactory.swift b/Source/ShoutFactory.swift index 37b99c6..bf5d6c1 100644 --- a/Source/ShoutFactory.swift +++ b/Source/ShoutFactory.swift @@ -102,7 +102,7 @@ open class ShoutView: UIView { backgroundView.addGestureRecognizer(tapGestureRecognizer) addGestureRecognizer(panGestureRecognizer) - NotificationCenter.default.addObserver(self, selector: #selector(ShoutView.orientationDidChange), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(ShoutView.orientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil) } public required init?(coder aDecoder: NSCoder) { @@ -110,7 +110,7 @@ open class ShoutView: UIView { } deinit { - NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) + NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil) } // MARK: - Configuration diff --git a/Source/WhisperFactory.swift b/Source/WhisperFactory.swift index 380fe43..f7862b1 100644 --- a/Source/WhisperFactory.swift +++ b/Source/WhisperFactory.swift @@ -28,11 +28,16 @@ class WhisperFactory: NSObject { override init() { super.init() - NotificationCenter.default.addObserver(self, selector: #selector(WhisperFactory.orientationDidChange), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) + NotificationCenter.default.addObserver(self, + selector: #selector(WhisperFactory.orientationDidChange), + name: UIDevice.orientationDidChangeNotification, + object: nil) } deinit { - NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) + NotificationCenter.default.removeObserver(self, + name: UIDevice.orientationDidChangeNotification, + object: nil) } func craft(_ message: Message, navigationController: UINavigationController, action: WhisperAction) { @@ -237,14 +242,23 @@ class WhisperFactory: NSObject { if let tableView = viewController.view as? UITableView , viewController is UITableViewController { - tableView.contentInset = UIEdgeInsetsMake(tableView.contentInset.top + edgeInsetHeight, tableView.contentInset.left, tableView.contentInset.bottom, tableView.contentInset.right) + tableView.contentInset = UIEdgeInsets(top: tableView.contentInset.top + edgeInsetHeight, + left: tableView.contentInset.left, + bottom: tableView.contentInset.bottom, + right: tableView.contentInset.right) } else if let collectionView = viewController.view as? UICollectionView , viewController is UICollectionViewController { - collectionView.contentInset = UIEdgeInsetsMake(collectionView.contentInset.top + edgeInsetHeight, collectionView.contentInset.left, collectionView.contentInset.bottom, collectionView.contentInset.right) + collectionView.contentInset = UIEdgeInsets(top: collectionView.contentInset.top + edgeInsetHeight, + left: collectionView.contentInset.left, + bottom: collectionView.contentInset.bottom, + right: collectionView.contentInset.right) } else { for view in viewController.view.subviews { if let scrollView = view as? UIScrollView { - scrollView.contentInset = UIEdgeInsetsMake(scrollView.contentInset.top + edgeInsetHeight, scrollView.contentInset.left, scrollView.contentInset.bottom, scrollView.contentInset.right) + scrollView.contentInset = UIEdgeInsets(top: scrollView.contentInset.top + edgeInsetHeight, + left: scrollView.contentInset.left, + bottom: scrollView.contentInset.bottom, + right: scrollView.contentInset.right) } } } @@ -280,8 +294,7 @@ extension WhisperFactory: UINavigationControllerDelegate { var maximumY = navigationController.navigationBar.frame.maxY - UIApplication.shared.statusBarFrame.height for subview in navigationController.navigationBar.subviews { - if subview is WhisperView { navigationController.navigationBar.bringSubview(toFront: subview) } - + if subview is WhisperView { navigationController.navigationBar.bringSubviewToFront(subview) } if subview.frame.maxY > maximumY && !(subview is WhisperView) { maximumY = subview.frame.maxY } diff --git a/Source/WhistleFactory.swift b/Source/WhistleFactory.swift index 679ba2b..5f6ae35 100644 --- a/Source/WhistleFactory.swift +++ b/Source/WhistleFactory.swift @@ -55,7 +55,7 @@ open class WhistleFactory: UIViewController { view.addGestureRecognizer(tapGestureRecognizer) - NotificationCenter.default.addObserver(self, selector: #selector(WhistleFactory.orientationDidChange), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(WhistleFactory.orientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil) } public required init?(coder aDecoder: NSCoder) { @@ -63,7 +63,7 @@ open class WhistleFactory: UIViewController { } deinit { - NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) + NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil) } // MARK: - Configuration @@ -96,7 +96,7 @@ open class WhistleFactory: UIViewController { } func moveWindowToFront() { - whistleWindow.windowLevel = view.isiPhoneX ? UIWindowLevelNormal : UIWindowLevelStatusBar + whistleWindow.windowLevel = view.isiPhoneX ? UIWindow.Level.normal : UIWindow.Level.statusBar setNeedsStatusBarAppearanceUpdate() } @@ -117,7 +117,7 @@ open class WhistleFactory: UIViewController { NSString(string: text).boundingRect( with: CGSize(width: labelWidth, height: CGFloat.infinity), options: NSStringDrawingOptions.usesLineFragmentOrigin, - attributes: [NSAttributedStringKey.font: titleLabel.font], + attributes: [NSAttributedString.Key.font: titleLabel.font], context: nil ) titleLabelHeight = CGFloat(neededDimensions.size.height) @@ -172,7 +172,7 @@ open class WhistleFactory: UIViewController { }, completion: { _ in if let window = self.previousKeyWindow { window.isHidden = false - self.whistleWindow.windowLevel = UIWindowLevelNormal - 1 + self.whistleWindow.windowLevel = UIWindow.Level.normal self.previousKeyWindow = nil window.rootViewController?.setNeedsStatusBarAppearanceUpdate() } diff --git a/Whisper.xcodeproj/project.pbxproj b/Whisper.xcodeproj/project.pbxproj index aa0a8d6..330fbf1 100644 --- a/Whisper.xcodeproj/project.pbxproj +++ b/Whisper.xcodeproj/project.pbxproj @@ -240,7 +240,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -290,7 +290,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic";