O'Reilly logo

iOS 9 Game Development Essentials by Chuck Gaffney

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

Arrays, matrices, sets, and dictionaries

Variables and constants can represent a collection of various properties and objects. The most common collection types are arrays, matrices, sets, and dictionaries. An array is an ordered list of distinct objects; a matrix is, in short, an array of arrays; a set is an unordered list of distinct objects; and a dictionary is an unordered list that utilizes a key : value association with the data.

Arrays

Here's an example of an array in Swift:

let stageNames : [String] = ["Downtown Tokyo","Heaven Valley","Nether"]

The object stageNames is a collection of strings representing the names of a game's stages. Arrays are ordered by subscripts from 0 to array length -1. So, stageNames[0] would be Downtown Tokyo; stageNames[2] ...

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