7
Dive Into Swift Kristijan Frankovic

Dive Into Swift

  • Upload
    axilis

  • View
    191

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Dive Into Swift

Dive Into SwiftKristijan Frankovic

Page 2: Dive Into Swift

Swift Powerful, intuitive, safe, fast, interactive, concise… iOS, OS X, watchOS Object-oriented, functional, static, strong typing… Beta – June 2014 1.0 – September 2014 1.2 – April 2015 2.1 – October 21, 2015

Page 3: Dive Into Swift

Swift 1.2 vs 2.1 Xcode 6 (1.2) -> Xcode 7 (2.x) – bunch of syntax errors Migration assistant (Edit / Convert / To latest println -> print Join (“”, components) -> components.joinWithSeparator(“”)

Error handling (1.2)var error: NSError?var something = context!.executeFetchRequest(request, error: &error)

Error handling (2.x)do {

var something = context.executeFetchRequest(request)} catch let error as NSError {

// do something with error}

Page 4: Dive Into Swift

Swift vs Objective-C Objective-C:Person *franc = [[Person alloc] initWithName:@"Kristijan"];[franc sayHello];

var franc = Person(name:"Kristijan")franc.sayHello()

Swift:

Page 5: Dive Into Swift

Objective-C Compatibility Bridging

iOS was developed in Objective-C Virtually all iOS API is accessible seamlessly from Swift Special data types – easier use of iOS API from Obj-c

NSString, NSArray, NSDictionary, NSNumber (int, float, double, bool) Import Objective-C code in Swift project and vice-versa

Page 6: Dive Into Swift

DemoDemo code is available at GitHub Gist:

https://gist.github.com/kfrankovic/61da4e0210e4861603e1