From 8b4f7b697af1bf32e9e224552c5fab96d422d4f8 Mon Sep 17 00:00:00 2001 From: Andrey Yastrebov Date: Mon, 3 Apr 2017 11:27:40 +0300 Subject: [PATCH] - update to swift 3.1 --- .../project.pbxproj | 10 +++- .../AppDelegate.swift | 2 +- .../Base.lproj/LaunchScreen.storyboard | 15 +++--- .../Base.lproj/Main.storyboard | 29 ++++++------ .../ContentViewController.swift | 14 +++--- .../Misc/Appearance+Extension.swift | 16 +++---- .../Misc/ImageRenderer.swift | 10 ++-- .../Misc/UIColor+Extension.swift | 18 +++---- .../NavigationController/Appearance.swift | 8 ++-- .../AppearanceApplyingStrategy.swift | 22 ++++----- .../AppearanceNavigationController.swift | 47 +++++++++---------- ...avigationControllerAppearanceContext.swift | 16 +++---- .../RootViewController.swift | 18 +++---- 13 files changed, 115 insertions(+), 110 deletions(-) diff --git a/AppearanceNavigationController.xcodeproj/project.pbxproj b/AppearanceNavigationController.xcodeproj/project.pbxproj index 38cb67e..8a77785 100644 --- a/AppearanceNavigationController.xcodeproj/project.pbxproj +++ b/AppearanceNavigationController.xcodeproj/project.pbxproj @@ -131,11 +131,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0710; + LastUpgradeCheck = 0830; ORGANIZATIONNAME = Zen; TargetAttributes = { ADF894961BE0D3C800C35CAC = { CreatedOnToolsVersion = 7.1; + LastSwiftMigration = 0820; }; }; }; @@ -223,8 +224,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -267,8 +270,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -287,6 +292,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.1; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; @@ -299,6 +305,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.yalantis.AppearanceNavigationController; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -310,6 +317,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.yalantis.AppearanceNavigationController; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/AppearanceNavigationController/AppDelegate.swift b/AppearanceNavigationController/AppDelegate.swift index 3885ecf..c4fd76a 100644 --- a/AppearanceNavigationController/AppDelegate.swift +++ b/AppearanceNavigationController/AppDelegate.swift @@ -6,7 +6,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { return true } } diff --git a/AppearanceNavigationController/Base.lproj/LaunchScreen.storyboard b/AppearanceNavigationController/Base.lproj/LaunchScreen.storyboard index 1447b3c..1709aef 100644 --- a/AppearanceNavigationController/Base.lproj/LaunchScreen.storyboard +++ b/AppearanceNavigationController/Base.lproj/LaunchScreen.storyboard @@ -1,8 +1,12 @@ - - + + + + + - + + @@ -14,10 +18,9 @@ - + - - + diff --git a/AppearanceNavigationController/Base.lproj/Main.storyboard b/AppearanceNavigationController/Base.lproj/Main.storyboard index 86e06d0..d90ee6b 100644 --- a/AppearanceNavigationController/Base.lproj/Main.storyboard +++ b/AppearanceNavigationController/Base.lproj/Main.storyboard @@ -1,8 +1,12 @@ - - + + + + + - + + @@ -10,22 +14,19 @@ - + - - - - + + + - + - + - - @@ -51,9 +52,8 @@ - + - @@ -75,7 +75,6 @@ - diff --git a/AppearanceNavigationController/ContentViewController.swift b/AppearanceNavigationController/ContentViewController.swift index 8d69425..a4fb943 100644 --- a/AppearanceNavigationController/ContentViewController.swift +++ b/AppearanceNavigationController/ContentViewController.swift @@ -7,7 +7,7 @@ class ContentViewController: UIViewController, NavigationControllerAppearanceCon required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - navigationItem.rightBarButtonItem = editButtonItem() + navigationItem.rightBarButtonItem = editButtonItem } var appearance: Appearance? { @@ -18,7 +18,7 @@ class ContentViewController: UIViewController, NavigationControllerAppearanceCon // mark: - Actions - override func setEditing(editing: Bool, animated: Bool) { + override func setEditing(_ editing: Bool, animated: Bool) { super.setEditing(editing, animated: animated) setNeedsUpdateNavigationControllerAppearance() @@ -26,13 +26,13 @@ class ContentViewController: UIViewController, NavigationControllerAppearanceCon // mark: - AppearanceNavigationControllerContent - func prefersNavigationControllerToolbarHidden(navigationController: UINavigationController) -> Bool { + func prefersNavigationControllerToolbarHidden(_ navigationController: UINavigationController) -> Bool { // hide toolbar during editing - return editing + return isEditing } - func preferredNavigationControllerAppearance(navigationController: UINavigationController) -> Appearance? { + func preferredNavigationControllerAppearance(_ navigationController: UINavigationController) -> Appearance? { // inverse navigation bar color and status bar during editing - return editing ? appearance?.inverse() : appearance + return isEditing ? appearance?.inverse() : appearance } -} \ No newline at end of file +} diff --git a/AppearanceNavigationController/Misc/Appearance+Extension.swift b/AppearanceNavigationController/Misc/Appearance+Extension.swift index 1e092ae..6bb48d8 100644 --- a/AppearanceNavigationController/Misc/Appearance+Extension.swift +++ b/AppearanceNavigationController/Misc/Appearance+Extension.swift @@ -9,13 +9,13 @@ extension Appearance { let navigationBarColor = UIColor.randomColor() value.navigationBar.backgroundColor = navigationBarColor - value.navigationBar.tintColor = navigationBarColor.isBright ? UIColor.blackColor() : UIColor.whiteColor() + value.navigationBar.tintColor = navigationBarColor.isBright ? UIColor.black : UIColor.white let toolbarColor = UIColor.randomColor() value.toolbar.backgroundColor = toolbarColor - value.toolbar.tintColor = toolbarColor.isBright ? UIColor.blackColor() : UIColor.whiteColor() + value.toolbar.tintColor = toolbarColor.isBright ? UIColor.black : UIColor.white - value.statusBarStyle = navigationBarColor.brightness > 0.5 ? .Default : .LightContent + value.statusBarStyle = navigationBarColor.brightness > 0.5 ? .default : .lightContent return value } @@ -27,7 +27,7 @@ extension Appearance { value.navigationBar.tintColor = navigationBar.tintColor.inverse() value.toolbar.backgroundColor = toolbar.backgroundColor.inverse() value.toolbar.tintColor = toolbar.tintColor.inverse() - value.statusBarStyle = value.navigationBar.backgroundColor.isBright ? .Default : .LightContent + value.statusBarStyle = value.navigationBar.backgroundColor.isBright ? .default : .lightContent return value } @@ -35,10 +35,10 @@ extension Appearance { static let lightAppearance: Appearance = { var value = Appearance() - value.navigationBar.backgroundColor = UIColor.lightGrayColor() - value.navigationBar.tintColor = UIColor.whiteColor() - value.statusBarStyle = .LightContent + value.navigationBar.backgroundColor = UIColor.lightGray + value.navigationBar.tintColor = UIColor.white + value.statusBarStyle = .lightContent return value }() -} \ No newline at end of file +} diff --git a/AppearanceNavigationController/Misc/ImageRenderer.swift b/AppearanceNavigationController/Misc/ImageRenderer.swift index 2d2bf58..c05227f 100644 --- a/AppearanceNavigationController/Misc/ImageRenderer.swift +++ b/AppearanceNavigationController/Misc/ImageRenderer.swift @@ -4,16 +4,16 @@ import UIKit class ImageRenderer: NSObject { - class func renderImageOfColor(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) -> UIImage { + class func renderImageOfColor(_ color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) -> UIImage { UIGraphicsBeginImageContext(size); let context = UIGraphicsGetCurrentContext(); - CGContextSetFillColorWithColor(context, color.CGColor); - CGContextFillRect(context, CGRect(x:0, y:0, width: size.width, height: size.height)); + context?.setFillColor(color.cgColor); + context?.fill(CGRect(x:0, y:0, width: size.width, height: size.height)); let output = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); - return output; + return output!; } -} \ No newline at end of file +} diff --git a/AppearanceNavigationController/Misc/UIColor+Extension.swift b/AppearanceNavigationController/Misc/UIColor+Extension.swift index fabddba..3f6cdd0 100644 --- a/AppearanceNavigationController/Misc/UIColor+Extension.swift +++ b/AppearanceNavigationController/Misc/UIColor+Extension.swift @@ -6,17 +6,13 @@ extension UIColor { // used solution from http://stackoverflow.com/a/29806108/4405316 var brightness: CGFloat { - let colorSpace = CGColorGetColorSpace(CGColor) - let colorSpaceModel = CGColorSpaceGetModel(colorSpace) - var brightness: CGFloat = 0.0 - if colorSpaceModel == .RGB { - let components = CGColorGetComponents(CGColor) - brightness = ((components[0] * 299) + (components[1] * 587) + (components[2] * 114)) / 1000 - } else { - getWhite(&brightness, alpha: nil) - } - + guard let components = cgColor.components else { return brightness } + let redBrightness = components[0] * 299 + let greenBrightness = components[1] * 587 + let blueBrightness = components[2] * 114 + brightness = (redBrightness + greenBrightness + blueBrightness) / 1000 + return brightness } @@ -42,4 +38,4 @@ extension UIColor { alpha: CGFloat(arc4random_uniform(100)) / 100 ) } -} \ No newline at end of file +} diff --git a/AppearanceNavigationController/NavigationController/Appearance.swift b/AppearanceNavigationController/NavigationController/Appearance.swift index 5bbabff..fd966e0 100644 --- a/AppearanceNavigationController/NavigationController/Appearance.swift +++ b/AppearanceNavigationController/NavigationController/Appearance.swift @@ -6,13 +6,13 @@ public struct Appearance: Equatable { public struct Bar: Equatable { - var style: UIBarStyle = .Default + var style: UIBarStyle = .default var backgroundColor = UIColor(red: 234 / 255, green: 46 / 255, blue: 73 / 255, alpha: 1) - var tintColor = UIColor.whiteColor() + var tintColor = UIColor.white var barTintColor: UIColor? } - var statusBarStyle: UIStatusBarStyle = .Default + var statusBarStyle: UIStatusBarStyle = .default var navigationBar = Bar() var toolbar = Bar() } @@ -27,4 +27,4 @@ public func ==(lhs: Appearance.Bar, rhs: Appearance.Bar) -> Bool { public func ==(lhs: Appearance, rhs: Appearance) -> Bool { return lhs.statusBarStyle == rhs.statusBarStyle && lhs.navigationBar == rhs.navigationBar && lhs.toolbar == rhs.toolbar -} \ No newline at end of file +} diff --git a/AppearanceNavigationController/NavigationController/AppearanceApplyingStrategy.swift b/AppearanceNavigationController/NavigationController/AppearanceApplyingStrategy.swift index 985471f..283af54 100644 --- a/AppearanceNavigationController/NavigationController/AppearanceApplyingStrategy.swift +++ b/AppearanceNavigationController/NavigationController/AppearanceApplyingStrategy.swift @@ -2,16 +2,16 @@ import Foundation import UIKit import QuartzCore -public class AppearanceApplyingStrategy { +open class AppearanceApplyingStrategy { - public func apply(appearance: Appearance?, toNavigationController navigationController: UINavigationController, animated: Bool) { + open func apply(_ appearance: Appearance?, toNavigationController navigationController: UINavigationController, animated: Bool) { if let appearance = appearance { let navigationBar = navigationController.navigationBar let toolbar = navigationController.toolbar - if !navigationController.navigationBarHidden { + if !navigationController.isNavigationBarHidden { let background = ImageRenderer.renderImageOfColor(appearance.navigationBar.backgroundColor) - navigationBar.setBackgroundImage(background, forBarMetrics: .Default) + navigationBar.setBackgroundImage(background, for: .default) navigationBar.tintColor = appearance.navigationBar.tintColor navigationBar.barTintColor = appearance.navigationBar.barTintColor navigationBar.titleTextAttributes = [ @@ -19,15 +19,15 @@ public class AppearanceApplyingStrategy { ] } - if !navigationController.toolbarHidden { - toolbar.setBackgroundImage( + if !navigationController.isToolbarHidden { + toolbar?.setBackgroundImage( ImageRenderer.renderImageOfColor(appearance.toolbar.backgroundColor), - forToolbarPosition: .Any, - barMetrics: .Default + forToolbarPosition: .any, + barMetrics: .default ) - toolbar.tintColor = appearance.toolbar.tintColor - toolbar.barTintColor = appearance.toolbar.barTintColor + toolbar?.tintColor = appearance.toolbar.tintColor + toolbar?.barTintColor = appearance.toolbar.barTintColor } } } -} \ No newline at end of file +} diff --git a/AppearanceNavigationController/NavigationController/AppearanceNavigationController.swift b/AppearanceNavigationController/NavigationController/AppearanceNavigationController.swift index ce2c356..2396772 100644 --- a/AppearanceNavigationController/NavigationController/AppearanceNavigationController.swift +++ b/AppearanceNavigationController/NavigationController/AppearanceNavigationController.swift @@ -2,7 +2,7 @@ import Foundation import UIKit -public class AppearanceNavigationController: UINavigationController, UINavigationControllerDelegate { +open class AppearanceNavigationController: UINavigationController, UINavigationControllerDelegate { public required init?(coder decoder: NSCoder) { super.init(coder: decoder) @@ -10,7 +10,7 @@ public class AppearanceNavigationController: UINavigationController, UINavigatio delegate = self } - override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { + override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) delegate = self @@ -28,9 +28,9 @@ public class AppearanceNavigationController: UINavigationController, UINavigatio // MARK: - UINavigationControllerDelegate - public func navigationController( - navigationController: UINavigationController, - willShowViewController viewController: UIViewController, animated: Bool + open func navigationController( + _ navigationController: UINavigationController, + willShow viewController: UIViewController, animated: Bool ) { guard let appearanceContext = viewController as? NavigationControllerAppearanceContext else { return @@ -41,21 +41,21 @@ public class AppearanceNavigationController: UINavigationController, UINavigatio applyAppearance(appearanceContext.preferredNavigationControllerAppearance(self), animated: animated) // interactive gesture requires more complex logic. - guard let coordinator = viewController.transitionCoordinator() where coordinator.isInteractive() else { + guard let coordinator = viewController.transitionCoordinator, coordinator.isInteractive else { return } - coordinator.animateAlongsideTransition({ _ in }, completion: { context in - if context.isCancelled(), let appearanceContext = self.topViewController as? NavigationControllerAppearanceContext { + coordinator.animate(alongsideTransition: { _ in }, completion: { context in + if context.isCancelled, let appearanceContext = self.topViewController as? NavigationControllerAppearanceContext { // hiding navigation bar & toolbar within interaction completion will result into inconsistent UI state self.setNavigationBarHidden(appearanceContext.prefersNavigationControllerBarHidden(self), animated: animated) self.setToolbarHidden(appearanceContext.prefersNavigationControllerToolbarHidden(self), animated: animated) } }) - coordinator.notifyWhenInteractionEndsUsingBlock { context in - let key = UITransitionContextFromViewControllerKey - if context.isCancelled(), let from = context.viewControllerForKey(key) as? NavigationControllerAppearanceContext { + coordinator.notifyWhenInteractionEnds { context in + let key = UITransitionContextViewControllerKey.from + if context.isCancelled, let from = context.viewController(forKey: key) as? NavigationControllerAppearanceContext { // changing navigation bar & toolbar appearance within animate completion will result into UI glitch self.applyAppearance(from.preferredNavigationControllerAppearance(self), animated: true) } @@ -64,9 +64,9 @@ public class AppearanceNavigationController: UINavigationController, UINavigatio // mark: - Appearance Applying - private var appliedAppearance: Appearance? + fileprivate var appliedAppearance: Appearance? - private func applyAppearance(appearance: Appearance?, animated: Bool) { + fileprivate func applyAppearance(_ appearance: Appearance?, animated: Bool) { if appearance != nil && appliedAppearance != appearance { appliedAppearance = appearance @@ -75,7 +75,7 @@ public class AppearanceNavigationController: UINavigationController, UINavigatio } } - public var appearanceApplyingStrategy = AppearanceApplyingStrategy() { + open var appearanceApplyingStrategy = AppearanceApplyingStrategy() { didSet { applyAppearance(appliedAppearance, animated: false) } @@ -83,11 +83,10 @@ public class AppearanceNavigationController: UINavigationController, UINavigatio // mark: - Apperanace Update - func updateAppearanceForViewController(viewController: UIViewController) { + func updateAppearanceForViewController(_ viewController: UIViewController) { if let - context = viewController as? NavigationControllerAppearanceContext - where - viewController == topViewController && transitionCoordinator() == nil + context = viewController as? NavigationControllerAppearanceContext, + viewController == topViewController && transitionCoordinator == nil { setNavigationBarHidden(context.prefersNavigationControllerBarHidden(self), animated: true) setToolbarHidden(context.prefersNavigationControllerToolbarHidden(self), animated: true) @@ -95,17 +94,17 @@ public class AppearanceNavigationController: UINavigationController, UINavigatio } } - public func updateAppearance() { + open func updateAppearance() { if let top = topViewController { updateAppearanceForViewController(top) } } - override public func preferredStatusBarStyle() -> UIStatusBarStyle { - return appliedAppearance?.statusBarStyle ?? super.preferredStatusBarStyle() + override open var preferredStatusBarStyle : UIStatusBarStyle { + return appliedAppearance?.statusBarStyle ?? super.preferredStatusBarStyle } - override public func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation { - return appliedAppearance != nil ? .Fade : super.preferredStatusBarUpdateAnimation() + override open var preferredStatusBarUpdateAnimation : UIStatusBarAnimation { + return appliedAppearance != nil ? .fade : super.preferredStatusBarUpdateAnimation } -} \ No newline at end of file +} diff --git a/AppearanceNavigationController/NavigationController/NavigationControllerAppearanceContext.swift b/AppearanceNavigationController/NavigationController/NavigationControllerAppearanceContext.swift index 7bf0dfc..729de8e 100644 --- a/AppearanceNavigationController/NavigationController/NavigationControllerAppearanceContext.swift +++ b/AppearanceNavigationController/NavigationController/NavigationControllerAppearanceContext.swift @@ -4,33 +4,33 @@ import UIKit public protocol NavigationControllerAppearanceContext: class { - func prefersNavigationControllerBarHidden(navigationController: UINavigationController) -> Bool - func prefersNavigationControllerToolbarHidden(navigationController: UINavigationController) -> Bool - func preferredNavigationControllerAppearance(navigationController: UINavigationController) -> Appearance? + func prefersNavigationControllerBarHidden(_ navigationController: UINavigationController) -> Bool + func prefersNavigationControllerToolbarHidden(_ navigationController: UINavigationController) -> Bool + func preferredNavigationControllerAppearance(_ navigationController: UINavigationController) -> Appearance? func setNeedsUpdateNavigationControllerAppearance() } extension NavigationControllerAppearanceContext { - func prefersNavigationControllerBarHidden(navigationController: UINavigationController) -> Bool { + func prefersNavigationControllerBarHidden(_ navigationController: UINavigationController) -> Bool { return false } - func prefersNavigationControllerToolbarHidden(navigationController: UINavigationController) -> Bool { + func prefersNavigationControllerToolbarHidden(_ navigationController: UINavigationController) -> Bool { return true } - func preferredNavigationControllerAppearance(navigationController: UINavigationController) -> Appearance? { + func preferredNavigationControllerAppearance(_ navigationController: UINavigationController) -> Appearance? { return nil } func setNeedsUpdateNavigationControllerAppearance() { if let viewController = self as? UIViewController, - navigationController = viewController.navigationController as? AppearanceNavigationController + let navigationController = viewController.navigationController as? AppearanceNavigationController { navigationController.updateAppearanceForViewController(viewController) } } -} \ No newline at end of file +} diff --git a/AppearanceNavigationController/RootViewController.swift b/AppearanceNavigationController/RootViewController.swift index adaeab5..a7889ff 100644 --- a/AppearanceNavigationController/RootViewController.swift +++ b/AppearanceNavigationController/RootViewController.swift @@ -3,39 +3,39 @@ import UIKit class RootViewController: UITableViewController, NavigationControllerAppearanceContext { - private let values: [Appearance] = (0..<10).map { _ in Appearance.random() } + fileprivate let values: [Appearance] = (0..<10).map { _ in Appearance.random() } // mark: - UITableViewDataSource - override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return values.count } - override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier("Cell")! // fine for sample app + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")! // fine for sample app let appearance = values[indexPath.row] cell.contentView.backgroundColor = appearance.navigationBar.backgroundColor cell.textLabel?.textColor = appearance.navigationBar.tintColor cell.textLabel?.text = "Sample #\(indexPath.row + 1)" - cell.textLabel?.backgroundColor = UIColor.clearColor() + cell.textLabel?.backgroundColor = UIColor.clear return cell } // mark: - AppearanceNavigationControllerContext - func preferredNavigationControllerAppearance(navigationController: UINavigationController) -> Appearance? { + func preferredNavigationControllerAppearance(_ navigationController: UINavigationController) -> Appearance? { return Appearance.lightAppearance } // mark: - Segue - override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if let cell = sender as? UITableViewCell, - target = segue.destinationViewController as? ContentViewController, - index = tableView.indexPathForCell(cell)?.row + let target = segue.destination as? ContentViewController, + let index = tableView.indexPath(for: cell)?.row { target.appearance = values[index] }