O'Reilly logo

Swift Translation Guide for Objective-C Users: Develop and Design by Maurice Kelly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Optionals

An optional differs from a regular variable or constant because it can have two states: It either has some value, or it has no value. When Apple listed the features of their newly announced Swift language, optionals seemed to be one of the concepts that Objective-C developers found the most challenging.

Why? A few possible reasons:

Image The misconception that in Objective-C we already have optional variables—assigning nil to a pointer is possible, and that makes it an optional, right? Wrong!

Image The concept that, for there to be optional ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required