Preface |
|
xi | |
Acknowledgments |
|
xv | |
About the Author |
|
xvii | |
|
Chapter 1 Accustoming Yourself to Objective-C |
|
|
1 | (24) |
|
Item 1 Familiarize Yourself with Objective-C's Roots |
|
|
1 | (3) |
|
Item 2 Minimize Importing Headers in Headers |
|
|
4 | (4) |
|
Item 3 Prefer Literal Syntax over the Equivalent Methods |
|
|
8 | (4) |
|
Item 4 Prefer Typed Constants to Preprocessor #define |
|
|
12 | (5) |
|
Item 5 Use Enumerations for States, Options, and Status Codes |
|
|
17 | (8) |
|
Chapter 2 Objects, Messaging, and the Runtime |
|
|
25 | (48) |
|
Item 6 Understand Properties |
|
|
25 | (8) |
|
Item 7 Access Instance Variables Primarily Directly When Accessing Them Internally |
|
|
33 | (3) |
|
Item 8 Understand Object Equality |
|
|
36 | (6) |
|
Item 9 Use the Class Cluster Pattern to Hide Implementation Detail |
|
|
42 | (5) |
|
Item 10 Use Associated Objects to Attach Custom Data to Existing Classes |
|
|
47 | (3) |
|
Item 11 Understand the Role of objc_msgSend |
|
|
50 | (4) |
|
Item 12 Understand Message Forwarding |
|
|
54 | (8) |
|
Item 13 Consider Method Swizzling to Debug Opaque Methods |
|
|
62 | (4) |
|
Item 14 Understand What a Class Object Is |
|
|
66 | (7) |
|
Chapter 3 Interface and API Design |
|
|
73 | (42) |
|
Item 15 Use Prefix Names to Avoid Namespace Clashes |
|
|
73 | (5) |
|
Item 16 Have a Designated Initializer |
|
|
78 | (6) |
|
Item 17 Implement the description Method |
|
|
84 | (5) |
|
Item 18 Prefer Immutable Objects |
|
|
89 | (6) |
|
Item 19 Use Clear and Consistent Naming |
|
|
95 | (7) |
|
Item 20 Prefix Private Method Names |
|
|
102 | (2) |
|
Item 21 Understand the Objective-C Error Model |
|
|
104 | (5) |
|
Item 22 Understand the NSCopying Protocol |
|
|
109 | (6) |
|
Chapter 4 Protocols and Categories |
|
|
115 | (30) |
|
Item 23 Use Delegate and Data Source Protocols for Interobject Communication |
|
|
115 | (8) |
|
Item 24 Use Categories to Break Class Implementations into Manageable Segments |
|
|
123 | (4) |
|
Item 25 Always Prefix Category Names on Third-Party Classes |
|
|
127 | (3) |
|
Item 26 Avoid Properties in Categories |
|
|
130 | (3) |
|
Item 27 Use the Class-Continuation Category to Hide Implementation Detail |
|
|
133 | (7) |
|
Item 28 Use a Protocol to Provide Anonymous Objects |
|
|
140 | (5) |
|
Chapter 5 Memory Management |
|
|
145 | (42) |
|
Item 29 Understand Reference Counting |
|
|
145 | (8) |
|
Item 30 Use ARC to Make Reference Counting Easier |
|
|
153 | (9) |
|
Item 31 Release References and Clean Up Observation State Only in dealloc |
|
|
162 | (3) |
|
Item 32 Beware of Memory Management with Exception-Safe Code |
|
|
165 | (3) |
|
Item 33 Use Weak References to Avoid Retain Cycles |
|
|
168 | (5) |
|
Item 34 Use Autorelease Pool Blocks to Reduce High-Memory Waterline |
|
|
173 | (4) |
|
Item 35 Use Zombies to Help Debug Memory-Management Problems |
|
|
177 | (6) |
|
Item 36 Avoid Using retainCount |
|
|
183 | (4) |
|
Chapter 6 Blocks and Grand Central Dispatch |
|
|
187 | (46) |
|
Item 37 Understand Blocks |
|
|
188 | (6) |
|
Item 38 Create typedefs for Common Block Types |
|
|
194 | (3) |
|
Item 39 Use Handler Blocks to Reduce Code Separation |
|
|
197 | (6) |
|
Item 40 Avoid Retain Cycles Introduced by Blocks Referencing the Object Owning Them |
|
|
203 | (5) |
|
Item 41 Prefer Dispatch Queues to Locks for Synchronization |
|
|
208 | (5) |
|
Item 42 Prefer GCD to performSelector and Friends |
|
|
213 | (4) |
|
Item 43 Know When to Use GCD and When to Use Operation Queues |
|
|
217 | (3) |
|
Item 44 Use Dispatch Groups to Take Advantage of Platform Scaling |
|
|
220 | (5) |
|
Item 45 Use dispatch_once for Thread-Safe Single-Time Code Execution |
|
|
225 | (1) |
|
Item 46 Avoid dispatch_get_current_queue |
|
|
226 | (7) |
|
Chapter 7 The System Frameworks |
|
|
233 | (32) |
|
Item 47 Familiarize Yourself with the System Frameworks |
|
|
233 | (3) |
|
Item 48 Prefer Block Enumeration to for Loops |
|
|
236 | (7) |
|
Item 49 Use Toll-Free Bridging for Collections with Custom Memory-Management Semantics |
|
|
243 | (5) |
|
Item 50 Use NSCache Instead of NSDictionary for Caches |
|
|
248 | (4) |
|
Item 51 Keep initialize and load Implementations Lean |
|
|
252 | (6) |
|
Item 52 Remember that NSTimer Retains Its Target |
|
|
258 | (7) |
Index |
|
265 | |