From fa432e179bf0c7e8b5658476a9c0d29dc1e1dbc0 Mon Sep 17 00:00:00 2001 From: corin8823 Date: Mon, 5 Oct 2015 21:23:35 +0900 Subject: [PATCH] Convert Swift 2.0 --- SwiftyExtensions.xcodeproj/project.pbxproj | 2 ++ SwiftyExtensions/NSMutableAttributedString+Addtions.swift | 2 +- SwiftyExtensions/String+Extension.swift | 6 +++--- SwiftyExtensions/UIColor+Hex.swift | 6 +++--- SwiftyExtensions/UIViewController+UIStoryBoard.swift | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/SwiftyExtensions.xcodeproj/project.pbxproj b/SwiftyExtensions.xcodeproj/project.pbxproj index bff2bc2..f84a624 100644 --- a/SwiftyExtensions.xcodeproj/project.pbxproj +++ b/SwiftyExtensions.xcodeproj/project.pbxproj @@ -185,6 +185,8 @@ 015B5ADA1B6DD8DB0087F4D3 /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftMigration = 0700; + LastSwiftUpdateCheck = 0700; LastUpgradeCheck = 0640; ORGANIZATIONNAME = "yusuke takahashi"; TargetAttributes = { diff --git a/SwiftyExtensions/NSMutableAttributedString+Addtions.swift b/SwiftyExtensions/NSMutableAttributedString+Addtions.swift index feba8cb..292315d 100644 --- a/SwiftyExtensions/NSMutableAttributedString+Addtions.swift +++ b/SwiftyExtensions/NSMutableAttributedString+Addtions.swift @@ -13,7 +13,7 @@ extension NSMutableAttributedString { public convenience init(string: String, image: UIImage?, point: CGPoint = CGPointZero, index: Int = 0) { self.init(string: string) if let image = image { - var textAttachment = NSTextAttachment() + let textAttachment = NSTextAttachment() textAttachment.image = image textAttachment.bounds = CGRect(origin: point, size: image.size) let ns = NSAttributedString(attachment: textAttachment) diff --git a/SwiftyExtensions/String+Extension.swift b/SwiftyExtensions/String+Extension.swift index 5413046..4dac821 100644 --- a/SwiftyExtensions/String+Extension.swift +++ b/SwiftyExtensions/String+Extension.swift @@ -10,8 +10,8 @@ import Foundation extension String { - public func insert(#string: String, atIndex: Int) -> String { - return prefix(self, atIndex) + string + suffix(self, count(self) - atIndex) + public func insert(string string: String, atIndex: Int) -> String { + return String(self.characters.prefix(atIndex)) + string + String(self.characters.suffix(self.characters.count - atIndex)) } public func trim() -> String { @@ -22,7 +22,7 @@ extension String { let size = CGSize(width: width, height: CGFloat.max) let rect = self.boundingRectWithSize(size, - options: .UsesLineFragmentOrigin | .UsesFontLeading, + options: [.UsesLineFragmentOrigin, .UsesFontLeading], attributes: [NSFontAttributeName: font], context: nil) return rect.size.height } diff --git a/SwiftyExtensions/UIColor+Hex.swift b/SwiftyExtensions/UIColor+Hex.swift index c304a94..ce98b06 100644 --- a/SwiftyExtensions/UIColor+Hex.swift +++ b/SwiftyExtensions/UIColor+Hex.swift @@ -15,15 +15,15 @@ extension UIColor { var red: CGFloat = 0.0 var green: CGFloat = 0.0 var blue: CGFloat = 0.0 - var alpha: CGFloat = alpha + let alpha: CGFloat = alpha if rgba.hasPrefix("#") { - let index = advance(rgba.startIndex, 1) + let index = rgba.startIndex.advancedBy(1) let hex = rgba.substringFromIndex(index) let scanner = NSScanner(string: hex) var hexValue: CUnsignedLongLong = 0 if scanner.scanHexLongLong(&hexValue) { - switch (count(hex)) { + switch (hex.characters.count) { case 3: red = CGFloat((hexValue & 0xF00) >> 8) / 15.0 green = CGFloat((hexValue & 0x0F0) >> 4) / 15.0 diff --git a/SwiftyExtensions/UIViewController+UIStoryBoard.swift b/SwiftyExtensions/UIViewController+UIStoryBoard.swift index 67096f9..d776d6e 100644 --- a/SwiftyExtensions/UIViewController+UIStoryBoard.swift +++ b/SwiftyExtensions/UIViewController+UIStoryBoard.swift @@ -12,12 +12,12 @@ extension UIViewController { public class func initialLoadStoryboard() -> UIViewController { let storyboard = UIStoryboard(name: StringFromClass(self), bundle: nil) - return storyboard.instantiateInitialViewController() as! UIViewController + return storyboard.instantiateInitialViewController()! } public class func loadStoryboard() -> UIViewController { let className = StringFromClass(self) let storyboard = UIStoryboard(name: className, bundle: nil) - return storyboard.instantiateViewControllerWithIdentifier(className) as! UIViewController + return storyboard.instantiateViewControllerWithIdentifier(className) } } \ No newline at end of file