| Preface |
|
xv | |
| Acknowledgments |
|
xvi | |
| About This Book |
|
xviii | |
| Author Online |
|
xxi | |
| About The Cover Illustration |
|
xxii | |
| Part 1 Getting Started With Objective-C |
|
1 | (94) |
|
1 Building Your First iOS Application |
|
|
3 | (25) |
|
1.1 Introducing the iOS development tools |
|
|
4 | (1) |
|
Adapting the Cocoa frameworks for mobile devices |
|
|
4 | (1) |
|
1.2 Adjusting your expectations |
|
|
5 | (2) |
|
A survey of hardware specifications, circa mid-2011 |
|
|
6 | (1) |
|
Expecting an unreliable internet connection |
|
|
7 | (1) |
|
1.3 Using Xcode to develop a simple Coin Toss game |
|
|
7 | (8) |
|
Introducing Xcode-Apple's IDE |
|
|
8 | (1) |
|
|
|
8 | (1) |
|
|
|
9 | (3) |
|
|
|
12 | (3) |
|
1.4 Hooking up the user interface |
|
|
15 | (6) |
|
Adding controls to a view |
|
|
15 | (2) |
|
Connecting controls to source code |
|
|
17 | (4) |
|
1.5 Compiling the Coin Toss game |
|
|
21 | (1) |
|
1.6 Taking Coin Toss for a test run |
|
|
21 | (6) |
|
|
|
22 | (1) |
|
Using breakpoints to inspect the state of a running application |
|
|
23 | (1) |
|
Running the Coin Toss game in the iPhone simulator |
|
|
24 | (1) |
|
|
|
25 | (2) |
|
|
|
27 | (1) |
|
2 Data types, variables, and constants |
|
|
28 | (27) |
|
2.1 Introducing the Rental Manager application |
|
|
29 | (3) |
|
|
|
29 | (3) |
|
|
|
32 | (8) |
|
Counting on your fingers-integral numbers |
|
|
32 | (3) |
|
Filling in the gaps-floating-point numbers |
|
|
35 | (2) |
|
|
|
37 | (2) |
|
|
|
39 | (1) |
|
2.3 Displaying and converting values |
|
|
40 | (4) |
|
NSLog and Format Specifiers |
|
|
40 | (3) |
|
Type casts and type conversions |
|
|
43 | (1) |
|
2.4 Creating your own data types |
|
|
44 | (8) |
|
|
|
44 | (2) |
|
|
|
46 | (2) |
|
|
|
48 | (2) |
|
The importance of descriptive names |
|
|
50 | (2) |
|
2.5 Completing Rental Manager v1.0, App Store here we come! |
|
|
52 | (2) |
|
|
|
54 | (1) |
|
3 An introduction to objects |
|
|
55 | (19) |
|
3.1 A whirlwind tour of object-oriented programming concepts |
|
|
56 | (2) |
|
What's wrong with procedural-based languages such as C? |
|
|
56 | (1) |
|
|
|
56 | (1) |
|
|
|
57 | (1) |
|
Inheritance and polymorphism |
|
|
57 | (1) |
|
3.2 The missing data type: id |
|
|
58 | (1) |
|
3.3 Pointers and the difference between reference and value types |
|
|
59 | (3) |
|
|
|
59 | (1) |
|
Obtaining the address of a variable |
|
|
59 | (1) |
|
|
|
60 | (1) |
|
Comparing the values of pointers |
|
|
61 | (1) |
|
3.4 Communicating with objects |
|
|
62 | (4) |
|
Sending a message to an object |
|
|
62 | (1) |
|
Sending a message to a class |
|
|
63 | (1) |
|
Sending nonexistent messages |
|
|
64 | (1) |
|
|
|
65 | (1) |
|
|
|
66 | (3) |
|
|
|
66 | (1) |
|
Extracting characters from strings |
|
|
67 | (1) |
|
|
|
68 | (1) |
|
|
|
69 | (1) |
|
|
|
69 | (3) |
|
|
|
72 | (2) |
|
4 Storing data in collections |
|
|
74 | (21) |
|
|
|
75 | (7) |
|
|
|
75 | (1) |
|
|
|
76 | (1) |
|
Searching for array elements |
|
|
77 | (2) |
|
|
|
79 | (1) |
|
|
|
80 | (2) |
|
|
|
82 | (6) |
|
Constructing a dictionary |
|
|
82 | (2) |
|
Accessing dictionary entries |
|
|
84 | (1) |
|
|
|
85 | (1) |
|
Enumerating all keys and values |
|
|
86 | (2) |
|
|
|
88 | (3) |
|
|
|
89 | (1) |
|
|
|
90 | (1) |
|
|
|
90 | (1) |
|
4.4 Making the Rental Manager application data driven |
|
|
91 | (3) |
|
|
|
94 | (1) |
| Part 2 Building Your Own Objects |
|
95 | (106) |
|
|
|
97 | (27) |
|
5.1 Building custom classes |
|
|
98 | (1) |
|
Adding a new class to the project |
|
|
98 | (1) |
|
5.2 Declaring the interface of a class |
|
|
99 | (7) |
|
Instance variables (ivars) |
|
|
100 | (1) |
|
|
|
101 | (4) |
|
Fleshing out the header file for the CTRentalProperty class |
|
|
105 | (1) |
|
5.3 Providing an implementation for a class |
|
|
106 | (3) |
|
Defining method implementations |
|
|
106 | (1) |
|
Accessing instance variables |
|
|
106 | (1) |
|
|
|
107 | (1) |
|
Fleshing out the method file for the CTRentalProperty class |
|
|
108 | (1) |
|
|
|
109 | (6) |
|
|
|
109 | (3) |
|
Synthesizing property getters and setters |
|
|
112 | (1) |
|
|
|
113 | (2) |
|
5.5 Creating and destroying objects |
|
|
115 | (5) |
|
Creating and initializing objects |
|
|
115 | (1) |
|
|
|
116 | (2) |
|
Combining allocation and initialization |
|
|
118 | (1) |
|
|
|
119 | (1) |
|
5.6 Using the class in the Rental Manager application |
|
|
120 | (3) |
|
|
|
123 | (1) |
|
|
|
124 | (20) |
|
|
|
124 | (3) |
|
|
|
125 | (2) |
|
6.2 Adding new instance variables |
|
|
127 | (2) |
|
6.3 Accessing existing instance variables |
|
|
129 | (2) |
|
Manual getters and setters approach |
|
|
130 | (1) |
|
|
|
131 | (3) |
|
Overriding the description method |
|
|
132 | (2) |
|
|
|
134 | (2) |
|
|
|
134 | (1) |
|
|
|
135 | (1) |
|
|
|
136 | (2) |
|
Extending classes without subclassing |
|
|
136 | (1) |
|
|
|
136 | (2) |
|
Considerations when using categories |
|
|
138 | (1) |
|
6.7 Subclassing in your demo application |
|
|
138 | (5) |
|
Creating and subclassing CTLease |
|
|
139 | (1) |
|
Creating CTPeriodicLease as a subclass of CTLease |
|
|
140 | (1) |
|
Creating CTFixedLease as a subclass of CTLease |
|
|
141 | (2) |
|
|
|
143 | (1) |
|
|
|
144 | (19) |
|
|
|
145 | (1) |
|
7.2 Implementing a protocol |
|
|
146 | (4) |
|
Creating the protocol method callers |
|
|
147 | (1) |
|
Making a class conform to a protocol |
|
|
148 | (2) |
|
|
|
150 | (12) |
|
|
|
150 | (3) |
|
|
|
153 | (4) |
|
|
|
157 | (1) |
|
|
|
158 | (4) |
|
|
|
162 | (1) |
|
8 Dynamic typing and runtime type information |
|
|
163 | (14) |
|
8.1 Static vs. dynamic typing |
|
|
164 | (2) |
|
Making assumptions about the runtime type |
|
|
164 | (2) |
|
|
|
166 | (1) |
|
|
|
166 | (5) |
|
Methods, selectors, and implementations |
|
|
167 | (2) |
|
Handling unknown selectors |
|
|
169 | (1) |
|
|
|
170 | (1) |
|
8.4 Runtime type information |
|
|
171 | (3) |
|
Determining if a message will respond to a message |
|
|
171 | (1) |
|
Sending a message generated at runtime |
|
|
171 | (2) |
|
Adding new methods to a class at runtime |
|
|
173 | (1) |
|
8.5 Practical uses of runtime type introspection |
|
|
174 | (2) |
|
|
|
176 | (1) |
|
|
|
177 | (24) |
|
|
|
178 | (1) |
|
|
|
179 | (5) |
|
|
|
180 | (1) |
|
|
|
181 | (1) |
|
Determining the current retain count |
|
|
182 | (2) |
|
|
|
184 | (6) |
|
What is an autorelease pool? |
|
|
185 | (1) |
|
Adding objects to the autorelease pool |
|
|
185 | (1) |
|
Creating a new autorelease pool |
|
|
185 | (2) |
|
Releasing objects in a pool |
|
|
187 | (1) |
|
Why not use an autorelease pool for everything? |
|
|
187 | (3) |
|
|
|
190 | (2) |
|
9.5 Rules for object ownership |
|
|
192 | (1) |
|
9.6 Responding to low-memory warnings |
|
|
193 | (6) |
|
Implementing the UIApplicationDelegate protocol |
|
|
193 | (1) |
|
Overriding didReceiveMemmyWarning |
|
|
194 | (3) |
|
Observing the UIApplicationDidReceiveMemoryWarningNotification |
|
|
197 | (2) |
|
|
|
199 | (2) |
| Part 3 Making Maximum Use Of Framework Functionality |
|
201 | (87) |
|
10 Error and exception handling |
|
|
203 | (9) |
|
10.1 NSError-handling errors the Cocoa way |
|
|
204 | (2) |
|
|
|
204 | (1) |
|
Examining NSError's userinfo Dictionary |
|
|
205 | (1) |
|
10.2 Creating NSError objects |
|
|
206 | (4) |
|
Introducing RentalManagerAPI |
|
|
206 | (3) |
|
Handling and displaying RentalManagerAPI errors |
|
|
209 | (1) |
|
|
|
210 | (1) |
|
|
|
210 | (1) |
|
|
|
211 | (1) |
|
|
|
211 | (1) |
|
11 Key-Value Coding and NSPredicate |
|
|
212 | (16) |
|
11.1 Making your objects KVG-compliant |
|
|
213 | (4) |
|
Accessing properties via KVC |
|
|
214 | (1) |
|
|
|
215 | (1) |
|
Returning multiple values |
|
|
215 | (1) |
|
Aggregating and collating values |
|
|
216 | (1) |
|
11.2 Handling special cases |
|
|
217 | (2) |
|
|
|
217 | (1) |
|
|
|
218 | (1) |
|
11.3 Filtering and matching with predicates |
|
|
219 | (5) |
|
|
|
219 | (1) |
|
|
|
220 | (1) |
|
Expressing your predicate condition |
|
|
220 | (1) |
|
|
|
221 | (1) |
|
Using key paths in predicate expressions |
|
|
222 | (1) |
|
Parameterizing and templating predicate expressions |
|
|
223 | (1) |
|
|
|
224 | (3) |
|
|
|
227 | (1) |
|
12 Reading and writing application data |
|
|
228 | (29) |
|
|
|
229 | (2) |
|
|
|
229 | (2) |
|
|
|
231 | (1) |
|
|
|
231 | (1) |
|
Persistent store coordinator |
|
|
231 | (1) |
|
|
|
232 | (1) |
|
|
|
232 | (1) |
|
|
|
232 | (2) |
|
|
|
232 | (1) |
|
|
|
233 | (1) |
|
|
|
234 | (1) |
|
12.4 Building the PocketTasks application |
|
|
234 | (17) |
|
Examining the Xcode Core Data template |
|
|
234 | (1) |
|
|
|
235 | (1) |
|
Defining the relationships |
|
|
236 | (1) |
|
Creating Person entities in pure code |
|
|
237 | (2) |
|
Fetching Person entities in pure code |
|
|
239 | (1) |
|
Adding a master Table View |
|
|
240 | (3) |
|
Adding and deleting people |
|
|
243 | (6) |
|
Man aging tasks 246 Using model objects |
|
|
249 | (2) |
|
|
|
251 | (5) |
|
|
|
251 | (2) |
|
|
|
253 | (1) |
|
Error handling and validation |
|
|
253 | (3) |
|
|
|
256 | (1) |
|
13 Blocks and Grand Central Dispatch |
|
|
257 | (19) |
|
13.1 The syntax of blocks |
|
|
258 | (7) |
|
|
|
260 | (2) |
|
Blocks and memory management |
|
|
262 | (2) |
|
Block-based APIs in Apple's iOS frameworks |
|
|
264 | (1) |
|
13.2 Performing work asynchronously |
|
|
265 | (9) |
|
|
|
266 | (1) |
|
GCD fundamentals 266 Building RealEstateViewer |
|
|
267 | (4) |
|
Making the image search asynchronous |
|
|
271 | (2) |
|
Making the image loading asynchronous |
|
|
273 | (1) |
|
|
|
274 | (2) |
|
|
|
276 | (12) |
|
14.1 Building an application, complete with bugs |
|
|
277 | (1) |
|
|
|
278 | (3) |
|
14.3 Bringing memory leaks under control with Instruments |
|
|
281 | (3) |
|
|
|
284 | (2) |
|
|
|
286 | (2) |
| Appendix A Installing the iOS SDK |
|
288 | (5) |
| Appendix B The basics of C |
|
293 | (19) |
| Appendix C Alternatives to Objective-C |
|
312 | (15) |
| Index |
|
327 | |