From f99592b76d0640e3762e65706fb03cb8f478d379 Mon Sep 17 00:00:00 2001 From: Batuhan Saka Date: Sun, 29 Jul 2018 14:45:34 +0300 Subject: [PATCH 1/2] Deprecation warnings solved. Warning: "Using '!' in this location is deprecated and will be removed in a future release; consider changing this to '?' instead." There was a warning in several lines. I solved them. +++ Added guard let statement to fix that issue on before the iteration in viewDidLoad(). --- Spring/DesignableTabBarController.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Spring/DesignableTabBarController.swift b/Spring/DesignableTabBarController.swift index dc55036..0ef83de 100644 --- a/Spring/DesignableTabBarController.swift +++ b/Spring/DesignableTabBarController.swift @@ -47,7 +47,7 @@ import UIKit @IBInspectable var firstSelectedImage: UIImage? { didSet { if let image = firstSelectedImage { - var tabBarItems = self.tabBar.items as [UITabBarItem]! + var tabBarItems = self.tabBar.items as [UITabBarItem]? tabBarItems?[0].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) } } @@ -56,7 +56,7 @@ import UIKit @IBInspectable var secondSelectedImage: UIImage? { didSet { if let image = secondSelectedImage { - var tabBarItems = self.tabBar.items as [UITabBarItem]! + var tabBarItems = self.tabBar.items as [UITabBarItem]? tabBarItems?[1].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) } } @@ -65,7 +65,7 @@ import UIKit @IBInspectable var thirdSelectedImage: UIImage? { didSet { if let image = thirdSelectedImage { - var tabBarItems = self.tabBar.items as [UITabBarItem]! + var tabBarItems = self.tabBar.items as [UITabBarItem]? tabBarItems?[2].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) } } @@ -74,7 +74,7 @@ import UIKit @IBInspectable var fourthSelectedImage: UIImage? { didSet { if let image = fourthSelectedImage { - var tabBarItems = self.tabBar.items as [UITabBarItem]! + var tabBarItems = self.tabBar.items as [UITabBarItem]? tabBarItems?[3].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) } } @@ -83,7 +83,7 @@ import UIKit @IBInspectable var fifthSelectedImage: UIImage? { didSet { if let image = fifthSelectedImage { - var tabBarItems = self.tabBar.items as [UITabBarItem]! + var tabBarItems = self.tabBar.items as [UITabBarItem]? tabBarItems?[4].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) } } @@ -92,7 +92,9 @@ import UIKit override func viewDidLoad() { super.viewDidLoad() - for item in self.tabBar.items as [UITabBarItem]! { + guard let items = self.tabBar.items as [UITabBarItem]? else { return } + + for item in items { if let image = item.image { item.image = image.imageWithColor(tintColor: self.normalTint).withRenderingMode(UIImageRenderingMode.alwaysOriginal) } From d6843cf41b6ad3e6f0b314351c15bcda265c0c8c Mon Sep 17 00:00:00 2001 From: Batuhan Saka Date: Sun, 29 Jul 2018 14:49:41 +0300 Subject: [PATCH 2/2] Deprecated property removed on extensions. 'character' property removed on extensions. Now, works like a 'variable.count' --- Spring/Misc.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Spring/Misc.swift b/Spring/Misc.swift index b2a27ce..902e7b3 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -23,7 +23,7 @@ import UIKit public extension String { - public var length: Int { return self.characters.count } + public var length: Int { return self.count } public func toURL() -> NSURL? { return NSURL(string: self) @@ -73,7 +73,7 @@ public extension UIColor { let scanner = Scanner(string: hex) var hexValue: CUnsignedLongLong = 0 if scanner.scanHexInt64(&hexValue) { - switch (hex.characters.count) { + switch (hex.count) { case 3: red = CGFloat((hexValue & 0xF00) >> 8) / 15.0 green = CGFloat((hexValue & 0x0F0) >> 4) / 15.0