Introduction to Swift 3

5 days

Select a date to register.

Course Description:

This course will give the student the necessary foundation in Swift 3 programming in order to later develop applications in Apple's Cocoa and iOS environments. It starts with the basics of programming in the Swift 3 programming language and finishes with the building of simple event-driven applications for the Apple Desktop and Mobile devices. There will also be some brief discussions of the Objective-C programming language which is still used in parts of the Cocoa and iOS environments. Once completed, the student will be ready to move on to the Cocoa and iOS courses.

What You Will Learn:

This course is designed to get you working efficiently and creatively in Swift. We have designed it as an effective combination between instructor-led demonstrations and guided labs to reinforce key concepts taught. You'll receive an introduction to the fundamentals of Swift programming and object-oriented concepts. You will learn about properties, looping structures, decision structures, classes and objects. In addition, troubleshooting code and debugging will be discussed.

Who Should Attend:

Programmers who will be involved in the development of applications for the Apple mobile and desktop environments.

Prerequisites:

Knowledge of programming concepts is helpful but not required for this course.

Course Outline:

(Note: Because Swift is an emerging language Apple is releasing frequent updates. As a result, the following outline may be subject to last minute alterations not reflected here)

Day 1 - Types and Control Flow

Xcode 7 Playground

Variables and Constants

  • Primitive Types

Numbers

  • Integers
  • Floating-Point Numbers
  • Number Operations
  • Converting numbers between types

Strings

  • Unicode
  • String Interpolation

Conditionals

  • Ternary Statements
  • Nesting Conditionals
  • else if

Switch Statements

  • Range Statements
  • Value Binding
  • Where Clauses
  • Tuples
  • Pattern Matching

Loops

  • for-in Loops
  • for case
  • for Loops
  • while Loops
  • repeat-while Loops
  • Control Transfer Statements

Optionals

  • Optional Types
  • Optional Binding
  • Implicitly Unwrapped Optionals
  • Optional Chaining
  • The Nil Coalescing Operator

Day 2 - Functions and Built-In Data Structures

Functions

  • Function Parameters
  • Parameter Names
  • Variadic Parameters
  • Default Parameter Values
  • In-out Parameters
  • Function Returns
  • Nested Functions
  • Tuple Returns
  • Optional Returns
  • Exiting from a Function
  • Function Types

Arrays

  • Accessing and Modifying Arrays
  • Array Equality
  • Adding and Removing Values
  • Looping
  • Immutable Arrays

Dictionaries

  • Accessing and Modifying a Dictionary
  • Adding and Removing Values
  • Looping
  • Immutable Dictionaries
  • Translating a Dictionary to an Array

Sets

  • Getting a Set
  • Working with Sets

Day 3 - Closures, Enumerations, Structures, and Classes

Closures

  • Closure Expression Syntax
  • Functions as Return Types
  • Functions as Arguments
  • Capture Values
  • Reference Types
  • Functional Programming

Enumerations

  • Methods
  • Associated Values
  • Recursive Enumerations

Structs and Classes

  • Structures
  • Instance Methods
  • Classes
  • Inheritance
  • Method Parameters

Day 4 - Properties, Initialization, and Protocols

Properties

  • Basic Stored Properties
  • Nested Properties
  • Lazy Stored Properties
  • Computed Properties
  • Getters and Setters
  • Type Properties
  • Access Control

Initialization

  • Struct Initialization
  • Class Initialization
  • Reinitialization
  • Failable Initializers

Value vs. Reference Types

  • Constant Value and Reference Types
  • Using Value and Reference Types Together
  • Copying
  • Identity vs. Equality

Protocols

  • Protocol Conformance
  • Protocol Inheritance
  • Protocol Composition
  • Mutating Methods

Day 5 - Error Handling, Extensions, Generics, Memory Management

Error Handling

  • Classes of Errors
  • Lexing an Input String
  • Catching Errors
  • Parsing the Token Array

Extensions

  • Extending an Existing Type
  • Extending a Custom Type

Generics

  • Generic Functions and Methods
  • Type Constants
  • Associated Type Protocols
  • Type Constraint where Clauses

Protocol Extensions

  • Modeling
  • Extending Type
  • Protocol Extension where Clauses
  • Default Implementations with Protocol Extensions

Memory Management and ARC

  • Strong Reference Cycles
  • Reference Cycles in Closures

Equatable and Comparable

  • Conforming to Equatable
  • Conforming to Comparable
  • Comparable’s Inheritance

A Cocoa Application

  • Model-View-Controller
  • Setting Up the View Controller
  • Setting Up Views in Interface Builder
  • Connections
  • Saving and Loading Documents

An iOS Application

  • Laying Out the User Interface
  • Connections

Interoperability

  • A brief overview of Objective-C
  • Adding Swift to Objective-C
  • Adding an Objective-C Class