iOS 5 Programming Cookbook
Vandad Nahavandipoor
Beijing
•
Cambridge
•
Farnham
•
Köln
•
Sebastopol
•
Tokyo
To Agnieszka Marta Dybowska.
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
1. The Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1
Creating a Simple iOS App in Xcode 2
1.2 Understanding Interface Builder 7
1.3
Compiling iOS Apps 13
1.4 Running iOS Apps on the Simulator 15
1.5
Running iOS Apps on iOS Devices 17
1.6
Packaging iOS Apps For Distribution 21
1.7
Declaring Variables in Objective-C 27
1.8 Comparing Values in Objective-C with an If Statement 29
1.9 Implementing Loops with For Statements 32
1.10 Implementing While Loops 35
1.11 Creating Custom Classes 37
1.12 Defining Functionality for Classes 42
1.13 Defining Two or More Methods with the Same Name 46
1.14
Allocating and Initializing Objects 49
1.15
Adding Properties to Classes 51
1.16
Moving from Manual Reference Counting to Automatic Reference
Counting 54
1.17
Typecasting with Automatic Reference Counting 59
1.18
Delegating Tasks with Protocols 63
1.19
Determining Whether Instance or Class Methods are Available 71
1.20
Determining Whether a Class is Available at Run Time 74
1.21
Allocating and Making Use of Strings 75
1.22
Allocating and Making Use of Numbers 79
1.23
Allocating and Making Use of Arrays 81
1.24
Allocating and Making Use of Dictionaries 86
1.25
Allocating and Making Use of Sets 89
1.26
Creating Bundles 92
1.27
Loading Data From the Main Bundle 93
1.28
Loading Data From Other Bundles 97
iii