[WWDC 2014] 402. Introduction to Swift

Key Principles

  • Safe
  • Modern
  • Power

Variables

Type Inference

Unicode Names

String

Building Complex Strings

String Mutability

Typed Collections

For-In: Ranges

For-In: Dictionaries

Modifying an Array

Optionals

Switch

  • Don’t need break !
  • Also not only int, but also objects!
  • siwtch must be exhaustive. default is necessary and important.

Default Parameter Values

Returning Values

Returning Multiple Values

Tuples

Decomposing a Tuples

Closures

Closures as Parameters

Classes

Computed Properties

Class Initialization

Overriding a Property

Property Observers

Structures in Swift

Structure or Class?

  • Class instances are passed by reference
  • Structures are passed by value

Mutating a Structure

Enumerations:Raw Values

Enumerations

Enumerations:Properties

Enumerations

Extensions

A Generic Stack Structure