My iOS 10 and Swift 3 Refactor List

I used an early beta of Xcode 8 to begin my conversion to Swift 3, which led to some issues so I had to do a lot of manual changes. Actually the conversion tool still works well a line at a time. Next Error followed by Return (CMD-‘, Return) is quite handy.

I thought it would be great to track them and keep a list in one place.

layerClass() method is now a variable:

override public class func layerClass() -> AnyClass {
    return CAEmitterLayer.self
}

override public class var layerClass: AnyClass {
    return CAEmitterLayer.self
}

Method signature in AppDelegate changed to:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }

Still unresolved: ??

CGAffineTransform.scale(transform, scale, scale)
CGAffineTransform.scaledBy(transform, scale, scale) ???
transform = CGAffineTransform(scaleX: scale, y:scale)

CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0)
context.setStrokeColor(red: 1, green: 0, blue: 1, alpha: 1)
[color getRed:&red0 green:&green0 blue:&blue0 alpha:&alpha0];
       var red0:CGFloat = 0
        var green0:CGFloat = 0
        var blue0:CGFloat = 0
        var alpha0:CGFloat = 0
color.getRed(&red0, green: &green0, blue: &blue0, alpha: &alpha0)
NSMakeRange(col, 1) // Unresolved
substringWithRange()
let x = rowString.substring(with: <#T##Range#>)
UIFont *aFont = [UIFont fontWithName:"American Typewriter" size:fontSize]
let aFont = UIFont(name:"American Typewriter", size:fontSize)
NSDictionary *attributes = @{NSFontAttributeName:  aFont}
let attributes = [NSFontAttributeName:  aFont]
UIRectCornerAllCorners
UIRectCorner.allCorners
xmlText.componentsSeparatedByString("\n")
xmlText.components(separatedBy: "\n")
anArray.joinWithSeparator(",")
anArray.joined(separator: ",")
String(contentsOfURL: xmlUrl)
String(contentsOf: xmlUrl)
url.componentsSeparatedByString("/")
url.components(separatedBy: "/")
"  foobar  ".stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
"  foobar  ".trimmingCharacters(in: NSCharacterSet.whitespaces)
NSTextAlignment.Center
NSTextAlignment.center
forState: .Normal
forState: .normal
.TouchUpInside 
.touchUpInside
url.rangeOfString("github.com")
url.contains("github.com")
// https://www.hackingwithswift.com/swift3
stringByReplacingOccurrencesOfString(" ", withString:"_")
"Hello, world".replacingOccurrences(of: "Hello", with: "Goodbye")
// https://swift.org/migration-guide/
DispatchQueue.GlobalAttributes.qosDefault
        DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async {

}

UIApplication.sharedApplication().
UIApplication.shared.

UIDevice.currentDevice().
UIDevice.current.
UIBezierPath(ovalInRect
UIBezierPath(ovalIn

touchesBegan() signature changed?

    override func touchesBegan(_ touches: Set, with event: UIEvent?) {
            if let touch = touches.first {
                let point = touch.location(in: self.superview)
            }

    }

moveToPoint()
move(to:
addLineToPoint()        
addLine(to: 
closePath()
close()
CGGradientCreateWithColors
CGColorSpaceCreateDeviceRGB
drawInRect
.draw(in: 
CGRectGetMaxX
CGRectGetMaxY

self.maxX
self.maxY
CGRectGetMidX()
CGRectGetMidY()

self.midX
self.midY
CGContextStrokePath(context)
context.strokePath()
CGContextSetLineWidth(context, 20)
context.setLineWidth(20)
CGRectInset()
self.bounds.insetBy(dx: 3, dy: 3)
self.view.bringSubviewToFront(cardFront)
self.view.bringSubview(toFront: cardFront)

self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier:CellIdentifier)

self.tableView.register(UITableViewCell.self, forCellReuseIdentifier:CellIdentifier)

self.showViewController(viewController, sender: self)
self.show(viewController, sender: self)
lowercaseString
lowercased()
//http://stackoverflow.com/questions/38964264/openurl-in-ios10

UIApplication.shared.openURL(URL(string: appStoreUrl)!)
UIApplication.shared.open(URL(string:appStoreUrl)!, options: [:])

type(of:)

CGColorRef

UIGraphicsPushContext(context);
UIGraphicsPopContext();

context.saveGState()
context.restoreGState()
CalendarIdentifierGregorian
Calendar.Identifier.gregorian
Calendar.currentCalendar()
Calendar.current
CalendarOptions
Calendar.Options
.dateFromComponents()
.date(from:)
.dateByAddingComponents()
Calendar.current.date(byAdding: dateComponents, to: )
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s