| Preface |
|
viii | |
| Acknowledgments |
|
x | |
| Part I: Introducing Objective-C |
|
1 | (136) |
|
Chapter 1 introducing Objective-C |
|
|
3 | (28) |
|
Using Xcode for Development |
|
|
4 | (8) |
|
|
|
4 | (3) |
|
Exploring the files in your project |
|
|
7 | (1) |
|
|
|
8 | (2) |
|
|
|
10 | (2) |
|
Understanding the Compilation Process |
|
|
12 | (11) |
|
|
|
12 | (3) |
|
Turning source code into compiled code and compiled code into an executable |
|
|
15 | (1) |
|
Exploring application bundles |
|
|
16 | (2) |
|
Working with build settings |
|
|
18 | (5) |
|
Using the Xcode Static Analyzer |
|
|
23 | (3) |
|
Understanding the Objective-C Runtime |
|
|
26 | (1) |
|
|
|
27 | (4) |
|
Chapter 2 Understanding Basic Syntax |
|
|
|
Working with Statements and Expressions |
|
|
31 | (20) |
|
|
|
32 | (3) |
|
|
|
35 | (1) |
|
|
|
35 | (2) |
|
Using special variable modifiers |
|
|
37 | (1) |
|
|
|
38 | (2) |
|
|
|
40 | (2) |
|
|
|
42 | (2) |
|
|
|
44 | (4) |
|
|
|
48 | (3) |
|
|
|
51 | (1) |
|
|
|
51 | (9) |
|
|
|
51 | (3) |
|
|
|
54 | (2) |
|
Understanding implementation versus interface |
|
|
56 | (2) |
|
Linking with implementation files |
|
|
58 | (2) |
|
|
|
60 | (10) |
|
Using conditional statements |
|
|
61 | (3) |
|
|
|
61 | (1) |
|
Using the ternary conditional |
|
|
62 | (1) |
|
|
|
63 | (1) |
|
Choosing among conditional statements |
|
|
64 | (1) |
|
|
|
64 | (12) |
|
|
|
65 | (1) |
|
|
|
65 | (1) |
|
Using for fast enumeration |
|
|
66 | (1) |
|
|
|
67 | (2) |
|
|
|
69 | (1) |
|
Applying What You Have Learned |
|
|
70 | (3) |
|
|
|
73 | (2) |
|
|
|
75 | (34) |
|
|
|
76 | (16) |
|
Understanding inheritance |
|
|
78 | (2) |
|
|
|
80 | (1) |
|
|
|
81 | (1) |
|
|
|
81 | (8) |
|
|
|
81 | (2) |
|
|
|
83 | (2) |
|
Working with the special object methods |
|
|
85 | (2) |
|
|
|
87 | (2) |
|
|
|
89 | (1) |
|
|
|
90 | (2) |
|
|
|
92 | (8) |
|
Understanding the differences between state and behavior |
|
|
92 | (7) |
|
Using properties to declare object state |
|
|
93 | (3) |
|
Understanding synthesized property accessors |
|
|
96 | (1) |
|
Using the nonatomic attribute |
|
|
97 | (1) |
|
Using the assign, retain, and copy Attributes |
|
|
98 | (1) |
|
Using properties with different data member names |
|
|
99 | (1) |
|
|
|
99 | (1) |
|
|
|
100 | (9) |
|
Creating the employee class |
|
|
101 | (3) |
|
Creating the manager class |
|
|
104 | (3) |
|
Tying the classes together in the HR main |
|
|
107 | (2) |
|
Chapter 4 Understanding Objective-C Memory Management |
|
|
109 | (28) |
|
|
|
109 | (14) |
|
Learning the memory management rules |
|
|
112 | (1) |
|
|
|
113 | (6) |
|
Understanding autorelease pools |
|
|
117 | (2) |
|
Understanding memory from inside the object |
|
|
119 | (4) |
|
|
|
119 | (2) |
|
|
|
121 | (2) |
|
|
|
123 | (5) |
|
Understanding the Garbage Collector |
|
|
123 | (3) |
|
Understanding reference types |
|
|
125 | (1) |
|
Configuring your project for garbage collection |
|
|
126 | (2) |
|
Using Frameworks in a Garbage Collected Project |
|
|
128 | (1) |
|
Exploring Key Garbage Collector Patterns |
|
|
128 | (7) |
|
Managing finite resources |
|
|
128 | (3) |
|
Writing foundation applications with garbage collection |
|
|
131 | (1) |
|
Working with objects in nib files |
|
|
132 | (1) |
|
Forcing garbage collection |
|
|
133 | (1) |
|
Working with void pointers and garbage collection |
|
|
133 | (1) |
|
Using the object oriented interface to the garbage collector |
|
|
134 | (1) |
|
Understanding What Memory Management Model to Use for Your Projects |
|
|
135 | (1) |
|
|
|
136 | (1) |
| Part II: Exploring Deeper Features |
|
137 | (120) |
|
Chapter 5 Working with Blocks |
|
|
|
|
|
139 | (5) |
|
|
|
140 | (2) |
|
|
|
142 | (2) |
|
Understanding Important Block Scoping |
|
|
144 | (4) |
|
Managing code block memory |
|
|
145 | (2) |
|
Making blocks easier to read with typedef |
|
|
147 | (1) |
|
Using Blocks with Threads |
|
|
148 | (1) |
|
Working with Grand Central Dispatch |
|
|
148 | (1) |
|
Using GCD functions to dispatch code blocks in threads |
|
|
148 | (1) |
|
Working with Common Block Design Patterns |
|
|
149 | (3) |
|
Using code blocks for maps |
|
|
149 | (1) |
|
Using Blocks in the Standard API |
|
|
150 | (2) |
|
Applying Blocks to an Embarrassingly Parallel Task. |
|
|
152 | (10) |
|
|
|
152 | (4) |
|
Using blocks with an array to filter for primes |
|
|
156 | (3) |
|
Using Grand Central Dispatch |
|
|
159 | (3) |
|
|
|
162 | (1) |
|
Chapter 6 Using Key Value Coding and Key Value Observing |
|
|
163 | (28) |
|
Accessing Object Properties Using Key Value Coding |
|
|
163 | (15) |
|
|
|
167 | (2) |
|
Writing KVC compliant accessors |
|
|
169 | (2) |
|
|
|
171 | (6) |
|
|
|
172 | (2) |
|
Using Unordered Accessors |
|
|
174 | (3) |
|
Using KVC with structures and scalars |
|
|
177 | (1) |
|
Searching objects for attributes |
|
|
177 | (1) |
|
Observing Changes to KC-Compliant Values |
|
|
178 | (8) |
|
|
|
179 | (1) |
|
Registering as an observer |
|
|
179 | (2) |
|
Defining callbacks for KVO |
|
|
181 | (2) |
|
|
|
183 | (1) |
|
Implementing manual notifications |
|
|
184 | (1) |
|
Understanding risks with KVO |
|
|
185 | (1) |
|
Applying Key Value Observing |
|
|
186 | (3) |
|
|
|
189 | (2) |
|
Chapter 7 Working with Protocols |
|
|
191 | (16) |
|
Favoring Composition Over Inheritance |
|
|
191 | (5) |
|
Understanding why you don't need (or want) multiple inheritance |
|
|
193 | (1) |
|
Understanding how protocols solve the problem |
|
|
194 | (1) |
|
Documenting an expected interface for others to implement |
|
|
195 | (1) |
|
Implementing Protocols in Your Objects. |
|
|
196 | (8) |
|
|
|
197 | (1) |
|
Dedaring that a dass implements a protocol |
|
|
198 | (2) |
|
Declaring an object that must implement a protocol |
|
|
200 | (1) |
|
Exploring formal and informal protocols |
|
|
200 | (1) |
|
Determining if an object implements optional methods |
|
|
201 | (2) |
|
Avoiding Circular Protocol Dependencies |
|
|
203 | (1) |
|
Exploring examples of protocol use |
|
|
204 | (1) |
|
|
|
205 | (2) |
|
Chapter 8 Extending Existing Class |
|
|
207 | (16) |
|
Working with Third-Party Frameworks and Classes |
|
|
207 | (1) |
|
|
|
208 | (8) |
|
|
|
209 | (1) |
|
Implementing category methods |
|
|
210 | (1) |
|
Declaring categories in header files |
|
|
211 | (1) |
|
|
|
211 | (1) |
|
Breaking up functionality using categories |
|
|
212 | (1) |
|
|
|
212 | (2) |
|
Exploring category limitations |
|
|
214 | (1) |
|
Implementing protocols with categories |
|
|
215 | (1) |
|
Understanding the dangers of creating categories on NSObject |
|
|
215 | (1) |
|
Extending Classes using Anonymous Categories |
|
|
216 | (2) |
|
Associating Variables with Existing Classes |
|
|
218 | (3) |
|
|
|
221 | (2) |
|
|
|
223 | (16) |
|
Reviewing the Compilation Process |
|
|
223 | (6) |
|
Understanding how macros work |
|
|
224 | (5) |
|
|
|
229 | (8) |
|
|
|
230 | (1) |
|
Passing constants by compilation |
|
|
231 | (1) |
|
Using variables in macros |
|
|
232 | (2) |
|
|
|
234 | (2) |
|
Handling conditional switching |
|
|
236 | (1) |
|
|
|
237 | (1) |
|
|
|
237 | (2) |
|
Chapter 10 Handling Errors |
|
|
239 | (18) |
|
|
|
239 | (2) |
|
Understanding how to interrupt program flow |
|
|
240 | (1) |
|
Using the Different Mechanisms for Error Handling |
|
|
241 | (14) |
|
|
|
241 | (3) |
|
|
|
244 | (6) |
|
|
|
250 | (9) |
|
Creating an NSError Object |
|
|
251 | (1) |
|
Understanding the NSError userInfo Dictionary |
|
|
252 | (1) |
|
Working with a recovery attempter |
|
|
253 | (1) |
|
Working with NSErrors in methods |
|
|
254 | (1) |
|
|
|
255 | (2) |
| Part III: Using the Foundation Framework |
|
257 | (54) |
|
Chapter 11 Understanding How the Framework Fit Together |
|
|
259 | (6) |
|
Understanding the Foundation Framework |
|
|
259 | (3) |
|
Exploring other frameworks |
|
|
261 | (1) |
|
Using Frameworks in Your Projects |
|
|
262 | (2) |
|
|
|
262 | (2) |
|
|
|
264 | (1) |
|
Considering garbage collection |
|
|
264 | (1) |
|
|
|
264 | (1) |
|
|
|
265 | (8) |
|
Understanding the String Declaration Syntax |
|
|
265 | (6) |
|
|
|
267 | (2) |
|
Working with Other NSString Methods |
|
|
269 | (2) |
|
Using NSString categories |
|
|
271 | (1) |
|
|
|
271 | (2) |
|
Chapter 13 Working with Collections |
|
|
273 | (22) |
|
|
|
273 | (10) |
|
|
|
276 | (4) |
|
|
|
280 | (1) |
|
|
|
281 | (2) |
|
Understanding Collections and Memory Management |
|
|
283 | (3) |
|
Using specialized collections |
|
|
285 | (1) |
|
|
|
286 | (2) |
|
Sending Messages to Elements |
|
|
288 | (1) |
|
|
|
289 | (3) |
|
Using Blocks with Collections |
|
|
292 | (1) |
|
|
|
293 | (2) |
|
Chapter 14 Using NSValue, NSNumber, and NSData |
|
|
295 | (8) |
|
Using NSValue and NSNumber 2% |
|
|
|
Wrapping arbitrary datatypes with NSValue |
|
|
296 | (1) |
|
Wrapping numbers with NSNumber |
|
|
297 | (1) |
|
Doing arithmetic with NSDecimalNumber |
|
|
298 | (1) |
|
Using NSData and NSMutableData |
|
|
299 | (2) |
|
|
|
299 | (1) |
|
Accessing the raw bytes in an NSData object |
|
|
300 | (1) |
|
|
|
301 | (2) |
|
Chapter 15 Working with Times and Dates |
|
|
303 | (8) |
|
|
|
304 | (1) |
|
Working with Time Intervals |
|
|
304 | (1) |
|
|
|
305 | (1) |
|
|
|
306 | (1) |
|
|
|
307 | (1) |
|
|
|
308 | (1) |
|
|
|
309 | (2) |
| Part IV: Exploring Advanced Topics |
|
311 | (50) |
|
Chapter 16 Multiprocessing with Threads |
|
|
313 | (16) |
|
|
|
314 | (5) |
|
|
|
315 | (2) |
|
Using the @synchronize keyword |
|
|
317 | (2) |
|
|
|
319 | (1) |
|
|
|
319 | (3) |
|
|
|
319 | (1) |
|
Manipulating Running Threads |
|
|
320 | (1) |
|
Accessing the main thread |
|
|
321 | (1) |
|
Crossing threads using perform selector |
|
|
322 | (1) |
|
Using NSOperation and NSOperationQueue |
|
|
322 | (6) |
|
|
|
323 | (2) |
|
Adding operations to queues |
|
|
325 | (1) |
|
Manipulating queue parameters |
|
|
326 | (1) |
|
Using other kinds of operations |
|
|
326 | (2) |
|
|
|
328 | (1) |
|
Chapter 17 Objective-C Design Patterns |
|
|
329 | (16) |
|
Recognizing Patterns in Solutions |
|
|
329 | (2) |
|
Describing Design Patterns in Objective-C |
|
|
331 | (12) |
|
|
|
331 | (5) |
|
|
|
331 | (1) |
|
|
|
331 | (3) |
|
|
|
334 | (2) |
|
Delegating responsibility |
|
|
336 | (3) |
|
|
|
336 | (1) |
|
|
|
336 | (2) |
|
|
|
338 | (1) |
|
Notifying objects of changes |
|
|
339 | (4) |
|
|
|
339 | (1) |
|
|
|
339 | (3) |
|
|
|
342 | (1) |
|
|
|
343 | (2) |
|
Chapter 18 Reading and writing Data with NSCoder |
|
|
345 | (10) |
|
Implementing the NSCoding Protocol in Your Objects |
|
|
345 | (1) |
|
|
|
345 | (2) |
|
|
|
347 | (1) |
|
Working with object graphs |
|
|
348 | (1) |
|
Using other types of data |
|
|
348 | (2) |
|
|
|
350 | (1) |
|
Using NSArchiver and NSUnarchiver |
|
|
351 | (1) |
|
Working with Archiver File Formats and Legacy Data |
|
|
352 | (1) |
|
|
|
353 | (2) |
|
Chapter 19 Using Objective-C on Other Platforms |
|
|
355 | (6) |
|
|
|
356 | (3) |
|
|
|
357 | (1) |
|
Using other open source libraries |
|
|
358 | (1) |
|
Looking Toward the Future |
|
|
359 | (1) |
|
|
|
359 | (2) |
| Index |
|
361 | |