Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift 3 Spelunking

Greg Heo
December 19, 2016

Swift 3 Spelunking

A talk about Swift 2, Swift 3, and the future. Silicon Valley iOS Developers' Meetup, December 19, 2016.

Greg Heo

December 19, 2016
Tweet

More Decks by Greg Heo

Other Decks in Technology

Transcript

  1. Silicon Valley iOS Developers' Meetup, December 2016
    Swift 3
    Spelunking @gregheo

    View full-size slide

  2. Swift 2 Swift 3 Swift 4
    ?
    current proposals

    View full-size slide

  3. #selector
    #keyPath
    Selector
    String

    View full-size slide

  4. @warn_unused_result
    @noescape

    View full-size slide

  5. @discardableResult
    @escaping

    View full-size slide

  6. #if swift(>=3.1)
    @available(swift 3.1)

    View full-size slide

  7. Any
    ‣ Classes — easy!
    ‣ _ObjectiveCBridgeable — easy!
    ‣ The rest: auto-box into _SwiftValue

    View full-size slide

  8. let t: Any.Type = type(of: 1 as Any)
    print(t is Int.Type) // CHECK: true
    print(t is Float.Type) // CHECK: false
    (swift/test/Interpreter/generic_casts.swift)

    View full-size slide

  9. NSNumber
    Int8
    Int16
    Int32
    Int64
    UInt8
    UInt16
    UInt32
    UInt64
    Float
    Double
    NSValue
    NSRange
    CGPoint
    CGVector
    CGSize
    CGRect
    CGAffineTransform
    CATransform3D
    CMTime
    MKCoordinate
    NSNull
    _SwiftNull
    Optionals

    View full-size slide

  10. [ NSError ] Error
    ConcreteError
    domain
    code
    userInfo
    localizedDescription
    localizedFailureReason
    localizedRecoverySuggestion
    localizedRecoveryOptions
    …and more

    View full-size slide

  11. [ NSError ]
    CustomNSError
    LocalizedError
    RecoverableError
    domain
    code
    userInfo
    localizedDescription
    localizedFailureReason
    localizedRecoverySuggestion
    localizedRecoveryOptions
    …and more

    View full-size slide

  12. #if os(OSX)
    #endif

    View full-size slide

  13. #if os(OSX) || os(iOS)
    #endif

    View full-size slide

  14. #if os(OSX) || os(iOS) || os(watchOS)
    #endif

    View full-size slide

  15. #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)
    #endif





    View full-size slide

  16. #if !os(Linux)
    // Apple platform!
    #else
    // Linux!
    #endif

    View full-size slide

  17. os()

    arch()

    swift()
    Linux, Windows, FreeBSD, …

    x86_64, arm, arm64, …

    by Swift version

    View full-size slide

  18. #if canImport(UIKit)
    // UIKit-based code
    #elseif canImport(Cocoa)
    // OSX code
    #elseif
    // Workaround/text, whatever
    #endif

    View full-size slide

  19. ORLY?
    tell me moar

    View full-size slide

  20. swiftunboxed.com

    View full-size slide

  21. apple.github.io/swift-evolution/

    View full-size slide

  22. Swift 3
    Spelunking @gregheo
    feedback

    View full-size slide

  23. Swift 3
    Spelunking @gregheo
    feedback

    View full-size slide