Skip to content

Commit

Permalink
Convert Swift 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
corin8823 committed Oct 5, 2015
1 parent 81f18fd commit fa432e1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions SwiftyExtensions.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@
015B5ADA1B6DD8DB0087F4D3 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0640;
ORGANIZATIONNAME = "yusuke takahashi";
TargetAttributes = {
Expand Down
2 changes: 1 addition & 1 deletion SwiftyExtensions/NSMutableAttributedString+Addtions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions SwiftyExtensions/String+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions SwiftyExtensions/UIColor+Hex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions SwiftyExtensions/UIViewController+UIStoryBoard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit fa432e1

Please sign in to comment.