Intermediate Swift Session 403 Playground

If you followed my last post I encouraged you to dive into the session 402 with my accompanying playground file. Download the intermediate playground here.

In session 403 — Intermediate Swift, Brian Lanier and Joe Groff build upon the previous session introducing more in depth use of optionals, memory, init, closures, and pattern matching.

Some highlights include:

  • optional binding directly to variables from the function.
Captured from Intermediate Swift Playground

  • optional chaining for deeply nested optional values
Captured from Intermediate Swift Playground

  • unowned reference types for dependent back references
Captured from Intermediate Swift Playground

  • memberwise structure initialization
Captured from Intermediate Swift Playground

  • convenience vs. designated initializers in swift
Captured from Intermediate Swift Playground

  • lazy properties delay initialization until they are called
  • deinit is available for classes that need it, i.e. to remove observers and the like
  • Implicit returns and arguments for closures
Captured from Intermediate Swift Playground

  • breaking strong reference cycles in closures using capture lists e.g. [unowned self]
Captured from Intermediate Swift Playground

  • pattern matching in switch statements
Captured from Intermediate Swift Playground

  • type patterns and the fallthrough statement
Captured from Intermediate Swift Playground

  • switch using tuple pattern and the where statement to quickly validate a structure
Captured from Intermediate Swift Playground

If you have made it this far, obviously you are interested. Grab the playground file and mess around in it while you watch the video to quickly get a grasp on what was introduced.


If you have any questions you can reach me @iJoeCollins on twitter.

Please recommend this post and subscribe to my newsletter!