$30 off During Our Annual Pro Sale. View Details »

What's new in Swift 2.0

What's new in Swift 2.0

Mark Wilkinson

March 30, 2016
Tweet

More Decks by Mark Wilkinson

Other Decks in Technology

Transcript

  1. SWIFT 2.0
    WHAT’S NEW WITH

    View Slide

  2. FIRST
    WHAT SWIFT 1.2 BROUGHT
    ▸ Speed enhancements, optimization in the runtime.
    Original issue with swift vs. obj-c
    ▸ if-let pyramids of doom deprecated
    ▸ Upcasts and Downcasts with as adds some optional safety
    ▸ Native Set added to the collection types
    ▸ let constants don’t have to be set at declaration
    ▸ Swift first-class citizenry enforced even more

    View Slide

  3. SWIFT 1.2
    BETTER OPTIONAL BINDING

    View Slide

  4. SWIFT 1.2
    UPCASTS AND DOWNCASTS

    View Slide

  5. SWIFT 1.2
    LET CONSTANTS

    View Slide

  6. SWIFT 1.2
    NULLABILITY ANNOTATIONS FOR BETTER OBJ-C TO SWIFT
    ▸ nonnull, nullable, null_unspecified
    ▸ originally anything in the Cocoa API returned to swift an
    unwrapped optional (AnyObject!)
    ▸ potentially bad if nothing was there, no way to know!
    crashed at runtime!
    ▸ much easier to handle things like UIKit with methods that
    will return optionals or guaranteed instances.

    View Slide

  7. SWIFT 1.2
    NULLABILITY ANNOTATIONS CONTINUED…

    View Slide

  8. SWIFT 2.0
    SWIFT 2.0 IS HERE
    ▸ Protocol extensions, default method implementations
    inside a protocol
    ▸ Error Handling, we now have throw, try, and catch !
    ▸ guard statement for better readability and early logic exit
    ▸ API availability statement
    ▸ Automatically synthesized headers

    View Slide

  9. SWIFT 2.0
    PROTOCOL EXTENSIONS

    View Slide

  10. SWIFT 2.0
    PROTOCOL EXTENSIONS CONTINUED…

    View Slide

  11. SWIFT 2.0
    YES YOU CAN OVERRIDE THE DEFAULT

    View Slide

  12. SWIFT 2.0
    ERROR HANDLING

    View Slide

  13. SWIFT 2.0
    GUARD STATEMENT

    View Slide

  14. SWIFT 2.0
    API AVAILABILITY

    View Slide

  15. SWIFT 2.0
    JUMP TO INTERFACE

    View Slide

  16. SWIFT 2.0
    CONVERT YOUR OBJ-C APPS NOW

    View Slide