About Me

Getting Started With Swift

Note To New Programmers: At this time I do not recommend learning Swift as your first language. It is still a very young language and therefore the resources and communities around it are not robust enough to allow it to be an effective first language. Also, the language itself is still buggy and in flux. When learning your first language, you want to be sure all problems are your fault and not potentially the fault of the technology you are using. This assumption can be made with more mature languages but not Swift yet. Instead, if you still want to start with iOS and/or OS X development, I recommend starting with Objective-C.

Read Apple’s Documentation

Before doing anything else, if you are truly serious about learning Swift and you are already familiar with other programming languages, Apple has already provided some great documentation for learning Swift:

Key Concepts

There are a few key concepts that I think are extremely important to learn that I want to highlight.

Optionals

Optionals are really important because variables cannot ever lack a value in Swift but it is still valuable to be able to represent a variable that can have no value or nil. It is also one of the biggest barriers to learning how to interact with Objective-C APIs and Apple’s frameworks because many variables in Objective-C are pointers meaning they can be nil. Optionals must be used in those cases.

You need to understand what an Optional is, how to check if it is nil, and how to “unwrap” it to access the actual value if it is not nil.

Constants v.s. Variables

There are two ways to declare a value in Swift. You can use let to indicate a constant and var to indicate a variable. You should always use let unless you have a reason to change a stored value.

Initialization

Initialization is much more restrictive in Swift than many other languages. There are more complicated rules around what order things must be initialized in and what variables must be set in an initializer. There is also a compiler made distinction between designated initializers and convenience initializers.

Automatic Reference Counting (ARC)

Memory management is not completely automatic in Swift. You still need to understand that there are different ownership relationships between objects. Most notably, you need to understand enough to prevent reference cycles in classes and reference cycles in closures.

Value and Reference Types

In Swift, there are two forms of types: Value Types and Reference Types. It is important that you understand the difference between them so that you can appropriately decide when to use each.

Generics

If you are not familiar with Generics from another language like C++, it can be hard to wrap you head around this change form Objective-C. In Objective-C it is common to use containers that store very generic types like id. Swift makes these containers safer using generics.

Follow Swift Tag on Stack Overflow

I have found it very valuable to follow the Swift tag on Stack Overflow. It is really great to see real world problems and solutions instead of the theoretical ones in a lot of documentation. It is even more valuable if you answer questions. Most people learn much better by doing and it is also really helpful to be forced to put your ideas into writing.

Follow Blogs

There are a few really great blogs that have cropped up already:

  • Drewag (This Blog) - A shameless plug for this blog. I will not be writing exclusively about Swift, but I plan to concentrate pretty heavily on it
  • Erica Sadun - Many great posts about Swift
  • Practical Swift - A blog dedicated to Swift

Listen To Podcasts

Podcasts give you a sense of the community and a constant learning opportunity. They are also great for learning while doing boring tasks like house work and driving. I have not found any dedicated Swift podcasts yet, but all of the following podcasts discuss Swift periodically and it is still valuable to keep up with what is happening in the Apple development world.

General News and Discussion

Technical

Specific Episodes