Learn Swift syntax with some sample playground files. Playgrounds are a new way to test out code in Xcode 6. We use this in our Apple Watch Meetup group.

Tutorial Playgrounds

Basic Syntax

  • Declaring variables and constants
  • Arrays, dictionaries, and optionals
  • Loops

Functions

  • Parameters and return values
  • Tuples
  • Simple algorithms using "if let" optionals

Design Objects

  • UIKit Views & Labels
  • Images
  • Class
  • Tables and DataSource

Advanced functions

  • Optional parameters
  • Generics and inout
  • Passing functions for Functional Programming
  • Higher-order functions — Sorted, Map, Filter, Reduce

SAMPLE CODE

Balloons

Apple demonstrated this playground when introducing Swift at WWDC. It features SpriteKit 2D animation special effects and includes documentation and suggestions for experimentation.

Patterns

A way to describe and match a set of values based on certain rules. It features enums and switch statements. It also includes documentation and suggestions for experimentation.

 

SceneKit

This playground features generated 3D shape toruses that spin around with animation.