1 Introduction |
|
1 | (6) |
|
What You Will Learn from This Book |
|
|
2 | (1) |
|
How This Book Is Organized |
|
|
3 | (2) |
|
|
5 | (1) |
|
|
5 | (1) |
|
Preface to the Fourth Edition |
|
|
6 | (1) |
2 Programming in Objective-C |
|
7 | (20) |
|
Compiling and Running Programs |
|
|
7 | (12) |
|
|
8 | (9) |
|
|
17 | (2) |
|
Explanation of Your First Program |
|
|
19 | (4) |
|
Displaying the Values of Variables |
|
|
23 | (2) |
|
|
25 | (1) |
|
|
25 | (2) |
3 Classes, Objects, and Methods |
|
27 | (24) |
|
What Is an Object, Anyway? |
|
|
27 | (1) |
|
|
28 | (2) |
|
An Objective-C Class for Working with Fractions |
|
|
30 | (3) |
|
|
33 | (4) |
|
|
34 | (1) |
|
Class and Instance Methods |
|
|
35 | (2) |
|
The @implementation Section |
|
|
37 | (2) |
|
|
39 | (6) |
|
Accessing Instance Variables and Data Encapsulation |
|
|
45 | (4) |
|
|
49 | (1) |
|
|
49 | (2) |
4 Data Types and Expressions |
|
51 | (20) |
|
|
51 | (4) |
|
|
51 | (1) |
|
|
52 | (1) |
|
|
52 | (1) |
|
Qualifiers: long, long long, short, unsigned, and signed |
|
|
53 | (1) |
|
|
54 | (1) |
|
|
55 | (9) |
|
|
55 | (3) |
|
Integer Arithmetic and the Unary Minus Operator |
|
|
58 | (2) |
|
|
60 | (1) |
|
Integer and Floating-Point Conversions |
|
|
61 | (2) |
|
|
63 | (1) |
|
|
64 | (1) |
|
|
65 | (2) |
|
|
67 | (4) |
5 Program Looping |
|
71 | (22) |
|
|
72 | (12) |
|
|
79 | (2) |
|
|
81 | (2) |
|
|
83 | (1) |
|
|
84 | (4) |
|
|
88 | (2) |
|
|
90 | (1) |
|
|
90 | (1) |
|
|
91 | (1) |
|
|
91 | (2) |
6 Making Decisions |
|
93 | (34) |
|
|
93 | (21) |
|
|
98 | (2) |
|
Compound Relational Tests |
|
|
100 | (3) |
|
|
103 | (2) |
|
|
105 | (9) |
|
|
114 | (3) |
|
|
117 | (5) |
|
|
122 | (2) |
|
|
124 | (3) |
7 More on Classes |
|
127 | (24) |
|
Separate Interface and Implementation Files |
|
|
127 | (5) |
|
Synthesized Accessor Methods |
|
|
132 | (2) |
|
Accessing Properties Using the Dot Operator |
|
|
134 | (1) |
|
Multiple Arguments to Methods |
|
|
135 | (5) |
|
Methods Without Argument Names |
|
|
137 | (1) |
|
|
137 | (3) |
|
|
140 | (5) |
|
|
141 | (1) |
|
|
141 | (4) |
|
|
145 | (1) |
|
Allocating and Returning Objects from Methods |
|
|
146 | (2) |
|
Extending Class Definitions and the Interface File |
|
|
148 | (1) |
|
|
148 | (3) |
8 Inheritance |
|
151 | (26) |
|
It All Begins at the Root |
|
|
151 | (5) |
|
|
155 | (1) |
|
Extension Through Inheritance: Adding New Methods |
|
|
156 | (13) |
|
A Point Class and Object Allocation |
|
|
160 | (1) |
|
|
161 | (4) |
|
Classes Owning Their Objects |
|
|
165 | (4) |
|
|
169 | (4) |
|
Which Method Is Selected? |
|
|
171 | (2) |
|
|
173 | (1) |
|
|
174 | (3) |
9 Polymorphism, Dynamic Typing, and Dynamic Binding |
|
177 | (18) |
|
Polymorphism: Same Name, Different Class |
|
|
177 | (3) |
|
Dynamic Binding and the id Type |
|
|
180 | (2) |
|
Compile Time Versus Runtime Checking |
|
|
182 | (1) |
|
The id Data Type and Static Typing |
|
|
183 | (2) |
|
Argument and Return Types with Dynamic Typing |
|
|
184 | (1) |
|
Asking Questions About Classes |
|
|
185 | (4) |
|
Exception Handling Using @try |
|
|
189 | (3) |
|
|
192 | (3) |
10 More on Variables and Data Types |
|
195 | (24) |
|
|
195 | (3) |
|
|
198 | (7) |
|
Directives for Controlling Instance Variable Scope |
|
|
198 | (2) |
|
More on Properties, Synthesized Accessors, and Instance Variables |
|
|
200 | (1) |
|
|
200 | (2) |
|
|
202 | (3) |
|
|
205 | (3) |
|
|
208 | (1) |
|
|
209 | (2) |
|
|
210 | (1) |
|
|
211 | (6) |
|
|
212 | (1) |
|
The Bitwise Inclusive-OR Operator |
|
|
213 | (1) |
|
The Bitwise Exclusive-OR Operator |
|
|
214 | (1) |
|
The Ones Complement Operator |
|
|
214 | (2) |
|
|
216 | (1) |
|
|
216 | (1) |
|
|
217 | (2) |
11 Categories and Protocols |
|
219 | (14) |
|
|
219 | (5) |
|
|
224 | (2) |
|
Some Notes About Categories |
|
|
225 | (1) |
|
|
226 | (4) |
|
|
229 | (1) |
|
|
229 | (1) |
|
|
230 | (1) |
|
|
231 | (2) |
12 The Preprocessor |
|
233 | (14) |
|
|
233 | (7) |
|
More Advanced Types of Definitions |
|
|
235 | (5) |
|
|
240 | (1) |
|
|
241 | (4) |
|
The #ifdef, #endif, #else |
|
|
241 | (2) |
|
The #if and #elif Preprocessor Statements |
|
|
243 | (1) |
|
|
244 | (1) |
|
|
245 | (2) |
13 Underlying C Language Features |
|
247 | (56) |
|
|
248 | (6) |
|
Initializing Array Elements |
|
|
250 | (1) |
|
|
251 | (1) |
|
|
252 | (2) |
|
|
254 | (8) |
|
Arguments and Local Variables |
|
|
255 | (2) |
|
Returning Function Results |
|
|
257 | (4) |
|
Functions, Methods, and Arrays |
|
|
261 | (1) |
|
|
262 | (4) |
|
|
266 | (7) |
|
|
269 | (1) |
|
Structures Within Structures |
|
|
270 | (2) |
|
Additional Details About Structures |
|
|
272 | (1) |
|
Don't Forget About Object-Oriented Programming! |
|
|
273 | (1) |
|
|
273 | (20) |
|
|
277 | (2) |
|
Pointers, Methods, and Functions |
|
|
279 | (1) |
|
|
280 | (6) |
|
Constant Character Strings and Pointers |
|
|
286 | (4) |
|
|
290 | (2) |
|
Pointers and Memory Addresses |
|
|
292 | (1) |
|
|
293 | (1) |
|
Miscellaneous Language Features |
|
|
293 | (5) |
|
|
293 | (1) |
|
|
294 | (1) |
|
|
294 | (1) |
|
|
294 | (1) |
|
|
295 | (1) |
|
|
296 | (2) |
|
|
298 | (2) |
|
Fact #1: Instance Variables Are Stored in Structures |
|
|
298 | (1) |
|
Fact #2: An Object Variable Is Really a Pointer |
|
|
299 | (1) |
|
Fact #3: Methods Are Functions, and Message Expressions Are Function Calls |
|
|
299 | (1) |
|
Fact #4: The id Type Is a Generic Pointer Type |
|
|
299 | (1) |
|
|
300 | (3) |
14 Introduction to the Foundation Framework |
|
303 | (4) |
|
|
303 | (4) |
15 Numbers, Strings, and Collections |
|
307 | (62) |
|
|
307 | (5) |
|
|
312 | (15) |
|
More on the NSLog Function |
|
|
312 | (1) |
|
|
313 | (1) |
|
Mutable Versus Immutable Objects |
|
|
314 | (6) |
|
|
320 | (7) |
|
|
327 | (27) |
|
|
330 | (17) |
|
|
347 | (7) |
|
|
354 | (4) |
|
|
355 | (3) |
|
|
358 | (7) |
|
|
362 | (3) |
|
|
365 | (4) |
16 Working with Files |
|
369 | (30) |
|
Managing Files and Directories: NSFileManager |
|
|
370 | (11) |
|
Working with the NSData Class |
|
|
375 | (1) |
|
|
376 | (3) |
|
Enumerating the Contents of a Directory |
|
|
379 | (2) |
|
Working with Paths: NSPathUtilities.h |
|
|
381 | (9) |
|
Common Methods for Working with Paths |
|
|
383 | (3) |
|
Copying Files and Using the NSProcessInfo Class |
|
|
386 | (4) |
|
Basic File Operations: NSFileHandle |
|
|
390 | (5) |
|
|
395 | (1) |
|
|
396 | (1) |
|
|
397 | (2) |
17 Memory Management and Automatic Reference Counting |
|
399 | (14) |
|
Automatic Garbage Collection |
|
|
401 | (1) |
|
Manual Reference Counting |
|
|
402 | (3) |
|
Object References and the Autorelease Pool |
|
|
403 | (2) |
|
The Event Loop and Memory Allocation |
|
|
405 | (2) |
|
Summary of Manual Memory Management Rules |
|
|
407 | (1) |
|
Automatic Reference Counting (ARC) |
|
|
408 | (1) |
|
|
408 | (1) |
|
|
409 | (1) |
|
|
410 | (1) |
|
Method Names and Non-ARC Compiled Code |
|
|
411 | (2) |
18 Copying Objects |
|
413 | (12) |
|
The copy and mutableCopy Methods |
|
|
413 | (3) |
|
Shallow Versus Deep Copying |
|
|
416 | (2) |
|
Implementing the <NSCopying> Protocol |
|
|
418 | (3) |
|
Copying Objects in Setter and Getter Methods |
|
|
421 | (2) |
|
|
423 | (2) |
19 Archiving |
|
425 | (18) |
|
Archiving with XML Property Lists |
|
|
425 | (2) |
|
Archiving with NSKeyedArchiver |
|
|
427 | (2) |
|
Writing Encoding and Decoding Methods |
|
|
429 | (7) |
|
Using NSData to Create Custom Archives |
|
|
436 | (3) |
|
Using the Archiver to Copy Objects |
|
|
439 | (2) |
|
|
441 | (2) |
20 Introduction to Cocoa and Cocoa Touch |
|
443 | (4) |
|
|
443 | (1) |
|
|
444 | (3) |
21 Writing iOS Applications |
|
447 | (32) |
|
|
447 | (1) |
|
Your First iPhone Application |
|
|
447 | (14) |
|
Creating a New iPhone Application Project |
|
|
449 | (3) |
|
|
452 | (3) |
|
|
455 | (6) |
|
An iPhone Fraction Calculator |
|
|
461 | (14) |
|
Starting the New Fraction_Calculator Project |
|
|
462 | (2) |
|
Defining the View Controller |
|
|
464 | (5) |
|
|
469 | (4) |
|
A Calculator Class That Deals with Fractions |
|
|
473 | (1) |
|
|
474 | (1) |
|
|
475 | (1) |
|
|
476 | (3) |
A Glossary |
|
479 | (8) |
B Address Book Example Source Code |
|
487 | (6) |
Index |
|
493 | |