O'Reilly logo

Swift Development with Cocoa by Tim Nugent, Jonathon Manning, Paris Buttfield-Addison

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 2. Programming with Swift

The Swift programming language is a new language for writing software for both iOS and OS X. Introduced in June 2014 at Apple’s Worldwide Developers Conference (WWDC), Swift was a surprise to everyone: Apple had managed to develop an entire language (as well as all of the supporting libraries, developer tools, and documentation), and made it work seamlessly with the existing Objective-C language. And on top of that, it’s a really good language.

Swift draws upon an extensive history of language design, and has a number of very cool design features that make developing software easier, simpler, and safer.

In this chapter, you’ll learn how to code in Swift.

The Swift Programming Language

The Swift programming language aims for the following goals:

Safety
Swift is designed to be a safe language. Many of the pitfalls of C, such as accidentally working with null pointers, are much harder to encounter. Swift is very strongly typed, and objects aren’t allowed to be null except under very specific circumstances.
Modernity
Swift contains a large number of modern language features designed to make it easy to express the logic of your code. These include features like pattern-matching switch statements (see Switches), closures (Closures), and the concept of all values being objects that you can attach properties and functions to (Extensions).
Power
Swift has access to the entire Objective-C runtime, and is seamlessly bridged to Objective-C’s classes. This ...

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