Chapter    9

Arrays and Dictionaries

Almost every program needs to accept data so it can manipulate that data and calculate a useful result. The simplest way to store data temporarily is through variables that can store numbers or text strings. However, what if you need to store multiple chunks of data such as a list of names or a list of product numbers? You could create multiple variables like this:

var employee001, employee002, employee003 : String

Unfortunately, creating separate variables to store related data can be clumsy. What if you don’t know how many items you need to store? Then you may create too many or not enough variables. Even worse, storing related data in separate variables means it’s easy to overlook the relationship between ...

Get Swift OS X Programming for Absolute Beginners 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.