ptg18651516
v
Table of Contents
Introduction ................................................................................................................... xiii
Prerequisites .......................................................................................................... xiii
What Has Changed in the Sixth Edition? .................................................................... xiii
Our Teaching Philosophy ......................................................................................... xiv
How to Use This Book ............................................................................................. xv
How This Book Is Organized .................................................................................... xv
Style Choices ........................................................................................................ xvii
Typographical Conventions ...................................................................................... xvii
Necessary Hardware and Software ............................................................................ xvii
1. A Simple iOS Application .............................................................................................. 1
Creating an Xcode Project .......................................................................................... 2
Model-View-Controller ............................................................................................... 5
Designing Quiz ......................................................................................................... 6
Interface Builder ....................................................................................................... 7
Building the Interface ................................................................................................ 8
Creating view objects ......................................................................................... 9
Configuring view objects .................................................................................. 12
Running on the simulator .................................................................................. 13
A brief introduction to Auto Layout ................................................................... 14
Making connections ......................................................................................... 17
Creating the Model Layer ......................................................................................... 22
Implementing action methods ............................................................................ 23
Loading the first question ................................................................................. 23
Building the Finished Application .............................................................................. 24
Application Icons .................................................................................................... 25
Launch Screen ........................................................................................................ 28
2. The Swift Language ..................................................................................................... 29
Types in Swift ........................................................................................................ 30
Using Standard Types ............................................................................................... 31
Inferring types ................................................................................................ 33
Specifying types .............................................................................................. 33
Literals and subscripting ................................................................................... 35
Initializers ...................................................................................................... 36
Properties ....................................................................................................... 37
Instance methods ............................................................................................. 37
Optionals ................................................................................................................ 38
Subscripting dictionaries ................................................................................... 40
Loops and String Interpolation ................................................................................... 40
Enumerations and the Switch Statement ...................................................................... 42
Enumerations and raw values ............................................................................. 43
Exploring Apple’s Swift Documentation ...................................................................... 44
3. Views and the View Hierarchy ....................................................................................... 45
View Basics ............................................................................................................ 46
The View Hierarchy ................................................................................................. 46
Creating a New Project ............................................................................................. 48