2. Collecting Your Data: Arrays and Dictionaries
This chapter talks about the types of collections that Swift has available. Objective-C has NSArray
and NSDictionary
through Cocoa. Swift is compatible and is used alongside Objective-C, so you have all those NS
tools available to you. In addition, you’ll have Swift’s native arrays and dictionaries available.
This chapter describes arrays and dictionaries and the different tools available in each. You will learn how to add and remove elements from collections. You will also learn how Swift’s strong type inference allows for quickly written and strongly typed arrays and dictionaries. You will learn when to use NSArray
s and when to use Swift’s own arrays.
Using Arrays
Arrays allow you to store stuff ...
Get Learning Swift 2 Programming, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.