With Swift, Apple has introduced a fast and innovative new programming language aimed specifically at iPhone, iPad and OS X App Development. Modern and concise, Swift represents a major departure from Objective-C in both structure and syntax as it introduces many new programming concepts. This course will thoroughly cover all the major features of Swift, from variable and constants declarations to working with collection objects, optionals, variadic and curried functions, tuples, closures, control-flow statements, and the creation of custom Swift classes.

This three-daycourse is aimed at creating a solid foundation in Swift programming to propel participants into iPhone, iPad and OS X app development.

Note: This class is recommended as the prerequisite/companion class to our five-day iOS App Development Using Swift.

Audience: Beginner programmers as well as experienced programmers who are not familiar with Swift.
Course Duration: 3 days
Prerequisites:

Previous programming experience is recommended but not mandatory. Basic familiarity with Mac computers and working in Mac OS X is also recommended.

Hardware and Software Requirements:
  • Mac computers running OS X 10.11 (“El Capitan”) or greater. An iOS device is optional
  • Xcode 7.3 (free download at: https://developer.apple.com/xcode/downloads/)
  • A projector with mini-HDMI adapter for the instructor
Course Objectives:
  • Learn to declare variables and constants, and use Swift’s different data types and perform type-casting operations
  • Create custom classes; use inheritance and subclassing
  • Write functions (basic, curried, variadic) and class methods
  • Work with optional variables, optional chaining, forced unwrapped optionals
  • Create collection objects using arrays and dictionaries
  • Declare and implement custom protocols
  • Write structs and enums
  • Create initializers, learn about designated initializers, convenience initializers and initializer delegation
  • Write full-fledged Swift apps
Course Outline:
  • Creating and Running a Swift Project in Xcode
    • Xcode IDE Overview
    • Creating and Using Playgrounds
    • Building and Testing Programs – Workflow

 

  • Working with Data Types, Variables and Constants
    • Variables and Constants
    • Data Types: Ints, Floats, Doubles, Bools, Chars, AnyObject
    • Strings: Literals, Mutability, Interpolation, Concatenation
    • Type Inference and Type-Safety
    • Type Casting
    • Unicode Characters in Variable Declaration

 

  • Working with Collection Objects
    • Arrays
      • Array Literals
      • Creating and Initializing Arrays
      • Accessing and Modifying Arrays
      • Iterating Over Arrays
      • Assignment and Copy Behavior for Arrays
    • Dictionaries
      • Dictionary Literals
      • Initializing
      • Modifying Dictionaries
      • Iterating Over Dictionaries
      • Assignment and Copy Behavior for Dictionaries
    • Collections Sequence Operations
      • Map
      • Filter
      • Reduce

 

  • Control-Flow
    • Conditionals
      • IF and Ternary Statements, Compound Relationals
      • Switch Statement: Switch with Strings, Range-Matching, Tuples, Value Bindings, WHERE clauses
      • Control Transfer Statements: Continue, Break, Fallthrough, Return
    • Loops
      • FOR loops, FOR-IN loops, FOR-Condition-Increment
      • WHILE loops, DO-WHILE loops

 

  • Writing Classes in Swift
    • Declaring a Swift Class in A Separate File
    • Declaring Stored and Computed Properties
    • Lazy Stored Properties
    • Working with Property Observers
    • Creating Instance Methods
    • Creating Class Methods and Class Properties
    • Creating Init Methods
    • Designated Initializers, Conveniences Initializers, Initializer Delegation
    • Deinitialization
    • Class Extensions

 

  • Inheritance
    • Base Classes, Creating Subclasses

 

  • Optionals
    • Forced Unwrapping
    • Optional Binding
    • Implicitly Unwrapped Optionals
    • Optional Chaining

 

  • Functions
    • Basic, Argumented and Variadic Parameters Functions
    • Inout Parameter Value Functions, Default Parameter Value Functions
    • Curried Functions and Nested Functions
    • Functions with Return types, Functions Returning Multiple/Tuple Types
    • Functions Returning Other Functions

 

  • Structures
    • Properties and Methods
    • Memberwise Initializers
    • Structures versus Classes

 

  • Enumerations
    • Declarations
    • Matching with Switch Statements
    • Associated Values
    • Raw Values

 

  • Generics
    • Generic Functions
    • Generic Types
    • Type Parameters
    • Extending Generic Types
    • Associated Types

 

  • Protocols
    • Protocol Declarations and Syntax
    • Property and Methods Requirements
    • Requiring Initializers
    • Protocol Types
    • Swift Standard Library Protocols
    • GeneratorType, SequenceType, CollectionType
    • Protocol Inheritance

 

  • Closures
    • Closure Expressions and Syntax
    • Closure Context Type Inference
    • Shorthand Argument Names
    • Trailing Closures

 

  • Error Handling
    • Prevent Crashes Due to System Generated Errors
    • Expose and Get Detailed Information on Thrown Errors
    • Create User-Defined Error-Types Using the ErrorType Protocol
    • Create Custom Functions to Throw Custom Errors

 

  • Additional Topics
    • Incorporating Objective-C Classes in a Swift Project
    • Incorporating Swift Classes in an Objective-C Project
    • Debugging
    • Unit Testing