Swift Programming Cheatsheet
Note: The Swift Cheatsheet is updated! Click here to grab the newer Swift 3 Cheatsheet
Learning a new programming language can be daunting. There’s so much to learn, so much to remember and worst of all: if you make one typing error, your code does not work.
For all aspiring app makers, I’ve made a Swift Programming Cheatsheet to help with that! A cheatsheet shows you most important Swift programming keywords, statements and concepts. While you learn, you can rely on the cheatsheet to help you rememember all those narly programming words.
The Swift Programming Cheatsheet includes:
- Variables. How do you declare and use a variable? It has ints, doubles, floats, strings, booleans, constants, optionals, expressions and inferred type variables.
- Methods. The other building block of programming: methods! Included are method definitions, method calls, arguments, return types and named parameters.
- Classes. One of the fundamental building blocks: classes. Learn about class definitions including subclassing, protocols, properties, outlets and lazy initialization.
- Instances. How do you use a class? With an instance of course! Learn how to declare an instance, call a method on it and set a property.
- Control Flow. Go with the flow? Nah! Control the flow of your code with if-statements, combined expressions, AND, OR, for-loops, while-loops and switches. Don’t forget order of precedence!
- Strings. Strings string together strings of characters, right? Here’s a few examples: optional conversion from String to Int, string interpolation, and declaration and initialization.
- Optionals. Optionals are simply variables that can be
nilduring their lifetime. Get the essence of optionals by learning about optional binding, force unwrapping and optional chaining.
- Dictionaries and Arrays. Ever need to store a list of something? Use an array or a dictionary! Learn how to declare, initialize and change them.
- Intermediate. Maybe you won’t need it, but just because it’s fun, let’s learn about these intermediate concepts: the nil-coalescing operator and downcasting, both optional and forced.
The cheatsheet is written for Swift 1.2 and tested on iOS 8.4 with Xcode 6.4. In the future, we’ll release a cheatsheet for Swift 2 of course.
Join 11.000+ app developers and marketers
- Get a weekly curated list of app development tools, articles and resources in your inbox
- 10x your app installs with relevant App Store Optimization and app marketing strategies
- BONUS: Grab a free copy of the App Toolbox 2017 to supercharge your next app project
Most Popular Content
Grab the App Toolbox 2017 to learn how to save time building your app,
and how to 10x your app installs in the App Store. With the toolbox, you'll immediately know how to move forward to build better, more profitable apps.
Comments & Thoughts
On The Blog
Best Of Quora: Android vs. iOS, Finding A Job, Prototyping And Gazing Into Space (Week 35)
This week's edition, topics include the Android vs. iOS debate, finding a job as a programmer, prototyping, coding clubs and gazing into the void of space.
How To Create An All-Star Team With Partners And Cofounders
Running a business isn't always easy, and it's definitely a ton of work. Why work alone if you can get farther together? In this article, you'll learn 3 great ways of finding and working together with co-founders and business partners. Synergy guaranteed!
What Do App Making And Solving World Hunger Have In Common, And Why Do We Give Up?
Learning how to code apps is a very popular topic these days. Look at any course site: Udemy, Team Treehouse, Lynda, Khan Academy, even Stanford Online and you’ll see hundreds of thousands of students enrolled in courses that teach them how to code apps. You’d expect that these courses produce a number of fresh app makers, but that’s not the case. Why not?