|
|
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 Sixth Edition |
|
|
6 | (1) |
|
I The Objective-C Language |
|
|
|
2 Programming in Objective-C |
|
|
7 | (20) |
|
Compiling and Running Programs |
|
|
7 | (1) |
|
|
8 | (8) |
|
|
16 | (2) |
|
Explanation of Your First Program |
|
|
18 | (4) |
|
Displaying the Values of Variables |
|
|
22 | (3) |
|
|
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 | (1) |
|
|
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 | (1) |
|
|
51 | (1) |
|
|
52 | (1) |
|
|
52 | (1) |
|
Qualifiers: long, long long, short, unsigned, and signed |
|
|
53 | (1) |
|
|
54 | (1) |
|
|
55 | (1) |
|
|
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) |
|
|
71 | (22) |
|
|
72 | (7) |
|
|
79 | (2) |
|
|
81 | (2) |
|
|
83 | (1) |
|
|
84 | (5) |
|
|
89 | (2) |
|
|
91 | (1) |
|
|
91 | (1) |
|
|
91 | (1) |
|
|
92 | (1) |
|
|
93 | (34) |
|
|
93 | (5) |
|
|
98 | (3) |
|
Compound Relational Tests |
|
|
101 | (3) |
|
|
104 | (1) |
|
|
105 | (10) |
|
|
115 | (3) |
|
|
118 | (5) |
|
|
123 | (2) |
|
|
125 | (2) |
|
|
127 | (26) |
|
Separate Interface and Implementation Files |
|
|
127 | (6) |
|
Synthesized Accessor Methods |
|
|
133 | (2) |
|
Accessing Properties Using the Dot Operator |
|
|
135 | (2) |
|
Multiple Arguments to Methods |
|
|
137 | (2) |
|
Methods without Argument Names |
|
|
139 | (1) |
|
|
139 | (4) |
|
|
143 | (1) |
|
|
144 | (1) |
|
|
144 | (4) |
|
|
148 | (1) |
|
Allocating and Returning Objects from Methods |
|
|
149 | (2) |
|
Extending Class Definitions and the Interface File |
|
|
151 | (1) |
|
|
151 | (2) |
|
|
153 | (26) |
|
It All Begins at the Root |
|
|
153 | (4) |
|
|
157 | (1) |
|
Extension through Inheritance: Adding New Methods |
|
|
158 | (4) |
|
A Point Class and Object Allocation |
|
|
162 | (1) |
|
|
163 | (4) |
|
Classes Owning Their Objects |
|
|
167 | (4) |
|
|
171 | (2) |
|
Which Method Is Selected? |
|
|
173 | (3) |
|
|
176 | (1) |
|
|
176 | (3) |
|
9 Polymorphism, Dynamic Typing, and Dynamic Binding |
|
|
179 | (18) |
|
Polymorphism: Same Name, Different Class |
|
|
179 | (3) |
|
Dynamic Binding and the id Type |
|
|
182 | (2) |
|
Compile Time Versus Runtime Checking |
|
|
184 | (1) |
|
The id Data Type and Static Typing |
|
|
185 | (1) |
|
Argument and Return Types with Dynamic Typing |
|
|
186 | (1) |
|
Asking Questions about Classes |
|
|
187 | (5) |
|
Exception Handling Using @try |
|
|
192 | (3) |
|
|
195 | (2) |
|
10 More on Variables and Data Types |
|
|
197 | (26) |
|
|
197 | (3) |
|
|
200 | (1) |
|
More on Properties, Synthesized Accessors, and Instance Variables |
|
|
201 | (1) |
|
|
202 | (2) |
|
|
204 | (3) |
|
|
207 | (3) |
|
|
210 | (1) |
|
|
211 | (1) |
|
|
212 | (1) |
|
|
213 | (2) |
|
|
215 | (1) |
|
The Bitwise Inclusive-OR Operator |
|
|
216 | (1) |
|
The Bitwise Exclusive-OR Operator |
|
|
216 | (1) |
|
The Ones Complement Operator |
|
|
217 | (1) |
|
|
218 | (1) |
|
|
219 | (1) |
|
|
220 | (3) |
|
11 Categories and Protocols |
|
|
223 | (14) |
|
|
223 | (5) |
|
|
228 | (1) |
|
Some Notes about Categories |
|
|
229 | (1) |
|
|
230 | (3) |
|
|
233 | (1) |
|
|
233 | (1) |
|
|
234 | (1) |
|
|
235 | (2) |
|
|
237 | (14) |
|
|
237 | (2) |
|
More Advanced Types of Definitions |
|
|
239 | (5) |
|
|
244 | (1) |
|
|
245 | (1) |
|
The #ifdef, #endif, #else, and #ifndef Statements |
|
|
245 | (2) |
|
The #if and #elif Preprocessor Statements |
|
|
247 | (1) |
|
|
248 | (1) |
|
|
249 | (2) |
|
13 Underlying C Language Features |
|
|
251 | (56) |
|
|
252 | (2) |
|
Initializing Array Elements |
|
|
254 | (1) |
|
|
255 | (1) |
|
|
256 | (2) |
|
|
258 | (1) |
|
Arguments and Local Variables |
|
|
259 | (2) |
|
Returning Function Results |
|
|
261 | (4) |
|
Functions, Methods, and Arrays |
|
|
265 | (1) |
|
|
266 | (4) |
|
|
270 | (3) |
|
|
273 | (1) |
|
Structures within Structures |
|
|
274 | (2) |
|
Additional Details about Structures |
|
|
276 | (1) |
|
Don't Forget about Object-Oriented Programming! |
|
|
277 | (1) |
|
|
277 | (4) |
|
|
281 | (2) |
|
Pointers, Methods, and Functions |
|
|
283 | (1) |
|
|
284 | (10) |
|
|
294 | (2) |
|
Pointers and Memory Addresses |
|
|
296 | (1) |
|
|
297 | (1) |
|
Miscellaneous Language Features |
|
|
297 | (1) |
|
|
297 | (1) |
|
|
298 | (1) |
|
|
298 | (1) |
|
|
299 | (1) |
|
|
299 | (1) |
|
|
300 | (2) |
|
|
302 | (2) |
|
Fact 1 Instance Variables Are Stored in Structures |
|
|
303 | (1) |
|
Fact 2 An Object Variable Is Really a Pointer |
|
|
303 | (1) |
|
Fact 3 Methods Are Functions, and Message Expressions Are Function Calls |
|
|
304 | (1) |
|
Fact 4 The id Type Is a Generic Pointer Type |
|
|
304 | (1) |
|
|
304 | (3) |
|
II The Foundation Framework |
|
|
|
14 Introduction to the Foundation Framework |
|
|
307 | (4) |
|
|
307 | (4) |
|
15 Numbers, Strings, and Collections |
|
|
311 | (66) |
|
|
311 | (6) |
|
|
317 | (1) |
|
More on the NSLog Function |
|
|
317 | (1) |
|
|
318 | (1) |
|
Mutable Versus Immutable Objects |
|
|
319 | (7) |
|
|
326 | (7) |
|
|
333 | (5) |
|
|
338 | (17) |
|
|
355 | (7) |
|
|
362 | (2) |
|
|
364 | (3) |
|
|
367 | (4) |
|
|
371 | (2) |
|
|
373 | (4) |
|
|
377 | (30) |
|
Managing Files and Directories: NSFileManager |
|
|
378 | (5) |
|
Working with the NSData Class |
|
|
383 | (1) |
|
|
384 | (3) |
|
Enumerating the Contents of a Directory |
|
|
387 | (2) |
|
Working with Paths: NSPathUtilities h |
|
|
389 | (3) |
|
Common Methods for Working with Paths |
|
|
392 | (2) |
|
Copying Files and Using the NSProcessInfo Class |
|
|
394 | (4) |
|
Basic File Operations: NSFileHandle |
|
|
398 | (5) |
|
|
403 | (1) |
|
|
404 | (1) |
|
|
405 | (2) |
|
17 Memory Management and Automatic Reference Counting |
|
|
407 | (12) |
|
Automatic Garbage Collection |
|
|
409 | (1) |
|
Manual Reference Counting |
|
|
409 | (1) |
|
Object References and the Autorelease Pool |
|
|
410 | (2) |
|
The Event Loop and Memory Allocation |
|
|
412 | (2) |
|
Summary of Manual Memory Management Rules |
|
|
414 | (1) |
|
Automatic Reference Counting |
|
|
415 | (1) |
|
|
415 | (1) |
|
|
416 | (1) |
|
|
417 | (1) |
|
Method Names and Non-ARC Compiled Code |
|
|
418 | (1) |
|
|
419 | (12) |
|
The copy and mutableCopy Methods |
|
|
419 | (3) |
|
Shallow Versus Deep Copying |
|
|
422 | (2) |
|
Implementing the <NSCopying> Protocol |
|
|
424 | (3) |
|
Copying Objects in Setter and Getter Methods |
|
|
427 | (2) |
|
|
429 | (2) |
|
|
431 | (18) |
|
Archiving with XML Property Lists |
|
|
431 | (3) |
|
Archiving with NSKeyedArchiver |
|
|
434 | (1) |
|
Writing Encoding and Decoding Methods |
|
|
435 | (7) |
|
Using NSData to Create Custom Archives |
|
|
442 | (4) |
|
Using the Archiver to Copy Objects |
|
|
446 | (1) |
|
|
447 | (2) |
|
III Cocoa, Cocoa Touch, and the iOS SDK |
|
|
|
20 Introduction to Cocoa and Cocoa Touch |
|
|
449 | (4) |
|
|
449 | (1) |
|
|
450 | (3) |
|
21 Writing iOS Applications |
|
|
453 | (32) |
|
|
453 | (1) |
|
Your First iPhone Application |
|
|
453 | (3) |
|
Creating a New iPhone Application Project |
|
|
456 | (4) |
|
|
460 | (2) |
|
|
462 | (7) |
|
An iPhone Fraction Calculator |
|
|
469 | (2) |
|
Starting the New Fraction_Calculator Project |
|
|
471 | (1) |
|
Defining the View Controller |
|
|
471 | (6) |
|
|
477 | (3) |
|
A Calculator Class That Deals with Fractions |
|
|
480 | (2) |
|
Designing the User Interface |
|
|
482 | (1) |
|
|
483 | (1) |
|
|
484 | (1) |
|
|
|
|
485 | (8) |
|
B Address Book Example Source Code |
|
|
493 | (6) |
Index |
|
499 | |