This Swift cheatsheet provides loads of code examples for language syntax and constructs.
Switches and optionals explains why optionals are a good fit for reducing the clunkiness in code around variables that may or may not have a value.
Swift Optionals: When to use if let, when ? and !, when as? and as digs into some of the confusing details behind force unwrapping, unwrapping and general variable optional handling in Swift.
Swift 2.0: Control Flow and Error Handling
examines the modification of Swift's do-while
loop to repeat-while
so
the do
statement could be introduced in 2.0. The post also covers the
guard
statement with a good IPv4 address parsing example, the defer
keyword and wraps up with 2.0's new error handling mechanisms. A good note
in the post is the explanation of the try!
(force try) keyword which
calls a function that can potentially throw an error and will terminate the
program with a runtime exception if an exception is thrown.
Apple's official Swift error handling page goes over the basics of representing, throwing and handlinge errors in programs.
Function currying is a concept Swift brings in from functional programming. Curried functions rewrite an existing function with multiple arguments into a new function with a single parameter as input and a function as returned output.
There is a solid language-agnostic Stack Overflow post on curried functions that defines what they are and shows their background comes from algebra functions.
Curried functions in Swift provides a concrete simple example of a curried function versus using a default parameter value.
This post explains that Instance Methods are Curried Functions in Swift and provides an example of how using function currying in some cases leads to cleaner code than in Objective-C.
The Human Interface Guidelines are Apple's vision and specific recommendations for creating effective user interfaces. There are different guidelines for iOS and OS X applications.
guard
StatementThe guard
statement is Swift 2 syntax for positively checking an error
condition and escaping from the immediate control flow, such as the current
function.
Swift 2.2: New Features goes into detail on the new features and some backwards-incompatible changes to the language since Swift 2.1.
About Swift is the official guide and language tour by Apple.
What's New in Swift 2? gives a high level overview for the new error handling, protocol extensions, and binding along with several other smaller additions that came with the new bump in the Swift version number.
Swift 2 - What's New? goes over some of the major changes in the Swift language and provides code for enums and the error handling syntax.
A Swift Adventure: Building BasicPhone with TwilioClient shows how to build a soft phone in iOS with Swift using Twilio Client for iOS.
Passwordless SMS Authentication: Part 2 – Building iOS Front End With Swift shows how to build an app that connects to a web service for authentication via SMS codes.
UIStackView is a way to lay out app user interface elements in iOS 9+ and Mac.
Getting Started with UIStackView along with the companion code in the GitHub repository provides a detailed tutorial for laying out elements, including ones that are added to the screen at runtime.
The blog post a first look at UIStackView in Swift 2.0 is a good starter tutorial along with the StackView GitHub repository example code. Note that the code will not compile with Swift 2.1 but if you fix the error in the way suggested by Xcode you'll be able to run the app without issues.
UIStackView tutorial is another solid walkthrough on StackViews.
A nascent community of server-side code libraries has sprung up since Swift was open sourced by Apple at the end of 2015. Most of these frameworks are not yet intended for production usage but over time some of them will emerge as favorites to build web applications.
Vapor is a framework inspired by Laravel, which is a PHP framework. There is an example project that demonstrates how a simple web application should be built with Vapor.
Swifton is an in-progress Ruby on Rails-inspired framework with routing, controllers, models and views similar to the model-view-controller pattern Rails web applications use.
Kitura is a web framework open sourced by IBM. This framework is intended to be easy to use with IBM's Bluemix cloud platform, if that's your kind of thing.
This server-side Swift post goes into using Vapor and shows how to deploy a "Hello World" application on Heroku.
NSHipster has a wide range of in-depth articles on Swift, Objective-C and Cocoa APIs. It is an awesome resource that's frequently updated with new articles by many of the best known developers in the Swift ecosystem.
Awesome Swift is yet another "awesome" list but it contains stacks of fantastic links to code libraries and tutorials broken down into categories such as security, user interfaces and dependency management.