UPDATED: The Swift 3 Cheatsheet

Written by: Reinder de Vries, September 22 2016, in App Development

Swift Cheatsheet, iOS Development with Swift 3

Why learn by heart if you can cheat? Grab this cheatsheet for Swift 3, including common syntax for primitives, basic classes, closures, error handling and more!

Updated for Swift 3

In This Cheatsheet…

Compared to the previous version of the cheatsheet, a lot has changed. It’s expanded, made clearer, upgraded and updated. Dare I say it’s the most Swifty edition yet?

This cheatsheet includes syntax examples for:

  • Variables, including primitives and common variable types
  • Functions, including function declaration and usage
  • Classes, including class declaration, protocols, outlets, properties, initializers, lazy properties and class methods
  • Instances, including initialization and using properties
  • Control Flow, including if-else if-else statements and switch
  • Loops, including for, while and Swift range syntax
  • Conditionals, including expressions, boolean logic and operators
  • Strings, including working with strings, converting from String to Int, and string interpolation
  • Optionals, including optional binding, optional chaining and force unwrapping
  • Dictionaries, including initialization and accessing key-value pairs
  • Arrays, including accessing values, adding values and looping over values
  • Closures, including complete closure syntax, capturing and escaping
  • Guard & Defer, including early return with guard and deferred execution with defer
  • Generics, including generic types and function generics
  • Tuples, because while I’m at it I might as well add tuple syntax too…
  • Error Handling, including throwing errors and catching them with do-try-catch

Swift 3: What’s New?

Swift 3 has recently been released and it’s the first major open-source iteration of the popular programming language for the Apple ecosystem (iOS, tvOS, watchOS and macOS).

The language update introduced a few big changes, including:

  • Omit needless words. No more stringByReplacingOccurrencesOfString ..., just replacingOccurences(of: ...!
  • Consistent use of English grammar for methods that return vs. change in-place.
  • No more NS prefix for basic classes – bye-bye NeXTSTEP!
  • Consistent lowerCamelCase for properties, methods and structs.
  • Together with the first point – all function arguments now have labels!

Swift 3 is the best Swift version yet, with many improvements over previous versions. Read up on all changes in this article.

Quick Note: Are you learning how to code iOS apps? Check out Zero to App Store, the extremely practical iOS development course I created. As a member you get access to our support forum, where your course instructors help you out, get you unstuck, and answer questions.
» Learn more about Zero to App Store

Further Reading

Save the whales, the trees and the arctic, and don’t print out this cheatsheet! Simply save it on your Desktop and keep it open while you’re coding.

Want to learn more? Check out these resources:

Enjoyed this article? Please share it!

Updated: The #Swift 3 Cheatsheet Click To Tweet

Written By: Reinder de Vries

Reinder de Vries is an indie app developer who teaches aspiring app developers and marketers how to build their own apps at LearnAppMaking.com. Since 2009 he has developed over 50 apps for iOS, Android and the web, and his code is used by millions of users all over the globe. When Reinder isn't building apps, he enjoys strong espresso and traveling.

Grab My Free iOS Development Course

Get complementary access to my course, Zero to App Store, and learn how you can build a real-time chat app with Firebase and Swift!

Yes, Send Me The Free Course!

Comments & Thoughts