I’m really happy to announce the latest course I’ve co-authored at DevelopMentor:
The Swift Programming Language
This course is specifically build to help teams of existing Objective-C developers quickly but thoroughly get up to speed with Swift. Here are details on the course, read more at DevelopMentor.
This course is a thorough introduction to the Swift language. If you have experience with Objective-C and Apple’s developers tools and APIs and you want you and your team to quickly get up to speed on Apple’s successor to Objective-C, then this hands-on course is the perfect one for you. The time to move to Swift is right now and this is the course to get you there.
New to Apple’s developer tools? We may have a better course for you. If you need a more rounded introduction including iOS and OS X SDKs (e.g. Cocoa Touch) and tooling (e.g. Xcode and storyboards), check out our Essential Swift iOS and OS X Programming which covers language and application topics.
When Apple announced the Swift programming language to cheering crowds at WWDC 2014, we knew it would be important. Swift is destined to replace the aging Objective-C language which was introduced over 32 years ago. Swift is built upon three core principles: safe, modern, and powerful. It fulfills these principles by borrowing the best features from modern languages such as Python, C#, modern C++, and others. While Swift adopts modern high-level language features it also improves upon Objective-C’s native performance and is actually faster than its predecessor.
While there are cross-platform options for building iOS and OS X applications, if you are ready to go all in on the Apple ecosystem you need to learn Swift today. This language fundamentals course is a great place to start.
Course outline and topics
Introduction to Swift for iOS and OS X
This first module introduces developers to the Swift ecosystem. You will learn why Swift was created and understand how it fits into the Apple developer ecosystem. You will learn about the various tools and SDKs needed to start building applications.
Swift is a modern language which borrows many of the best features from successful, established languages of the day such as Python and C#. Swift values readability and productivity over terseness. In this lesson, you will get a quick introduction to the major language features. We will see how to define variables and understand Swift’s variable scope. Next up is a variety of flow control constructs (if, while, etc.). We will pay special attention to loops in Swift, which has traditional for and while loops but also adds rich iteration and range based loop constructs. Finally we discuss how to import external libraries to extend our capabilities.
Optionals and Optional Chaining
The Swift language adds two clean and powerful features to the developer’s toolkit: optional chaining and generics. Unlike most languages, Swift types cannot be null / nil. Even though Swift has both value types and reference types, they must have a value. To specifically allow for missing values, Swift introduces optionals and optional chaining to work with these types. Using optional chaining you can entirely avoid those one-line if statements required to juggle null / nil optionals and reference types. We will also cover generics, a powerful feature to use strong-typed features in a general way.
Swift has a rich type system. This lesson explores some of the fundamental types and tips for working with them (numbers, strings, dates, etc.). You will see how to convert between types and parse text into common types (e.g. dates). You’ll learn about the most used operations on these types so you can jump right into using them in your applications.
Swift has a rich collection system. This lesson explores Swift’s collection classes (arrays, dictionaries, and tuples). These types have very powerful features and only some of them are covered in this lesson (saving the best for deeper examination later). You will learn to splice (via subscript ranges), combine, and generally manipulate these collections here.
Functions and Closures
Functions, along with classes, are key building blocks of any self-respecting language. Swift’s support for functions is very sophisticated. We start by defining basic functions and discussing parameters, return values, and related concepts. Unlike many languages, you will see that Swift functions naturally support returning multiple return values and assigning them all in one step. You will see how to define functions with varying numbers of parameters, how to create named parameters, and work with default and optional parameters. Finally we look at some of the best features of functions enabling modern, concise programming techniques: closures, expressions, and lambdas in Swift.
Swift is a first class object-oriented language. You will see how to define your own classes and how to add methods and fields to them. We will cover how to hook into object lifetime and initialization.
Structures and Enumerations
Classes are not the only way to define your own custom types in Swift. Structures allow many of the same features and functionality as classes but as a value type rather than reference type. Structures are key to high performance code in certain situations. You will also learn about enumerations which again share many features with classes and structures but they model situations where the set of data is a finite set (e.g. days of the week). You will also learn when you should use classes, when to use structures, and when to use enums.
Protocols and Extensions
Next up are two powerful features for extending, adapting, and reusing types. We will begin by learning about protocols. If you are coming from another language, you may know these as interfaces. Protocols allow your types (classes, structs, and enums) to guarantee they support a minimum level of functionality and allow for greater type reuse and polymorphism. Protocols work great when extending types you control. But Swift has another feature which allows you to add functionality and features to existing types even types imported from other libraries like the String class. These are extensions and they are a powerful feature not found in many other languages.
The Swift language is strongly-typed. While strong typing is usually an advantage it can also get in your way. This module will show you how to reuse algorithms in Swift irrespective of their types. This is done via generics, a powerful feature to use strong-typed features in a general way. You will see how to define custom generic types, factor elements of the type into your algorithms and restrict the types can be applied via type constraints and where clauses.
In this module, you will learn the ins-and-outs of memory management in Swift. Swift has two broad categories of types (reference types and value types) and you will see they differ dramatically in how memory is managed for these types. You will learn when and how to use each of these and how to identify them. We will see, that for reference types, Swift uses Automatic Reference Counting (ARC) to track and manage your app’s memory usage. In most cases, this means that memory management ‘just works’ in Swift, and you do not need to think about memory management yourself. We will discuss various types of references and see how they affect memory management (strong, weak, and unowned references) references.