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 12. Collections

Contrasting the support for collections between Objective-C and Swift initially seems a little unfair. The collections we know, love, and take for granted in Objective-C (NSArray, NSDictionary, and friends) are actually part of the Foundation framework, which leaves native C arrays as the only direct language-to-language comparison. Given, however, the extent to which the Foundation collections are used in iOS and OS X development, comparing their usage to Swift native collections does make sense.

Swift comes with two native collection types—arrays and dictionaries—and like strings in Swift they can be made immutable by declaring as a constant rather than as a variable. As collections they draw immediate parallels between ...

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