Introduction |
|
1 | (6) |
|
|
2 | (1) |
|
Conventions Used in This Book |
|
|
2 | (1) |
|
|
3 | (1) |
|
How This Book Is Organized |
|
|
3 | (2) |
|
Part I Getting to the Starting Line |
|
|
3 | (1) |
|
Part II Speaking the Language of Objective-C |
|
|
4 | (1) |
|
Part III Walking the Object-Oriented Walk |
|
|
4 | (1) |
|
Part IV Moving from Language to Application |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
5 | (1) |
|
|
6 | (1) |
|
|
6 | (1) |
|
Part I Getting to the Starting Line |
|
|
7 | (64) |
|
Chapter 1 Computer Programming Exposed! |
|
|
9 | (12) |
|
Why a Computer Program Is Like a Recipe |
|
|
10 | (4) |
|
Examining a simple computer program |
|
|
12 | (2) |
|
Understanding How Computer Languages Work |
|
|
14 | (3) |
|
Creating a computer program |
|
|
14 | (1) |
|
Running a computer program |
|
|
15 | (2) |
|
What Is Objective-C, Anyway? |
|
|
17 | (4) |
|
Understanding programming languages |
|
|
18 | (1) |
|
Running your program in a runtime environment |
|
|
19 | (1) |
|
Using frameworks and libraries |
|
|
19 | (1) |
|
Your suite of development tools |
|
|
20 | (1) |
|
|
20 | (1) |
|
Using Objective-C Version 2.0 |
|
|
20 | (1) |
|
Chapter 2 Creating Your First Program |
|
|
21 | (42) |
|
Getting Started with the Software Development Kit |
|
|
21 | (5) |
|
|
22 | (4) |
|
Creating Your Xcode Project |
|
|
26 | (18) |
|
|
31 | (1) |
|
|
32 | (3) |
|
Displaying an area's content |
|
|
35 | (2) |
|
|
37 | (2) |
|
The First Program Project |
|
|
39 | (1) |
|
|
39 | (2) |
|
|
41 | (3) |
|
Building and Running Your Application |
|
|
44 | (6) |
|
|
46 | (1) |
|
|
47 | (3) |
|
Customizing Xcode to Your Liking |
|
|
50 | (3) |
|
Getting to Know the Xcode Text Editor |
|
|
53 | (1) |
|
|
54 | (6) |
|
|
54 | (1) |
|
The header file for a symbol |
|
|
55 | (1) |
|
|
55 | (1) |
|
|
56 | (2) |
|
|
58 | (2) |
|
|
60 | (1) |
|
Working with the Examples |
|
|
61 | (2) |
|
Chapter 3 The Object in Objective-C |
|
|
63 | (8) |
|
Not All Modules Are Created Equal |
|
|
64 | (1) |
|
Understanding How Objects Behave |
|
|
65 | (2) |
|
Seeing the Concepts in Action |
|
|
67 | (3) |
|
|
67 | (2) |
|
|
69 | (1) |
|
|
70 | (1) |
|
Part II Speaking the Language of Objective-C |
|
|
71 | (162) |
|
Chapter 4 Language and Programming Basics |
|
|
73 | (38) |
|
It All Comes Down to Your Statements |
|
|
73 | (2) |
|
|
75 | (1) |
|
|
75 | (1) |
|
Understanding How Variables Work |
|
|
75 | (5) |
|
|
76 | (2) |
|
|
78 | (1) |
|
|
79 | (1) |
|
Giving Instructions with Operators |
|
|
80 | (19) |
|
Really learning how operators (and everything else) work in Objective-C |
|
|
80 | (1) |
|
Using arithmetic operators |
|
|
81 | (8) |
|
Back to variables --- floats |
|
|
89 | (3) |
|
|
92 | (1) |
|
Compound assignment operators |
|
|
93 | (2) |
|
Increment and decrement operators |
|
|
95 | (1) |
|
|
96 | (1) |
|
|
97 | (1) |
|
|
97 | (2) |
|
Making Logical Decisions in Your Code |
|
|
99 | (6) |
|
|
99 | (4) |
|
Relational and equality operators |
|
|
103 | (1) |
|
|
103 | (1) |
|
|
104 | (1) |
|
Accessing Data with Pointers |
|
|
105 | (1) |
|
|
106 | (3) |
|
Declared constants (const) |
|
|
107 | (1) |
|
Defined constants (#define) |
|
|
108 | (1) |
|
Knowing the Objective-C Reserved Words |
|
|
109 | (1) |
|
|
110 | (1) |
|
Chapter 5 Functions and Data Structures |
|
|
111 | (34) |
|
Thinking about an Application |
|
|
111 | (5) |
|
Defining and Declaring Data Structures |
|
|
116 | (3) |
|
|
119 | (3) |
|
|
122 | (12) |
|
|
130 | (2) |
|
|
132 | (1) |
|
|
133 | (1) |
|
Declaring Function Prototypes |
|
|
134 | (2) |
|
Extending the Functionality of a Program |
|
|
136 | (6) |
|
Thinking about Extensibility and Enhanceability |
|
|
142 | (3) |
|
Chapter 6 Adding a Little More Class to Your Program |
|
|
145 | (30) |
|
Grasping Objects and Their Classes |
|
|
145 | (1) |
|
Moving from Functions and Global Data to Objects and Classes |
|
|
146 | (2) |
|
|
148 | (8) |
|
Declaring the class interface |
|
|
149 | (6) |
|
Scoping instance variables |
|
|
155 | (1) |
|
The Implementation --- Coding the Methods |
|
|
156 | (3) |
|
Adding the implementation compiler directive |
|
|
156 | (1) |
|
Defining the createBudget: method |
|
|
157 | (1) |
|
Defining the rest of the methods |
|
|
158 | (1) |
|
Exploring the Program Logic |
|
|
159 | (6) |
|
Coding the functionality in the main function |
|
|
160 | (4) |
|
Building and running the application |
|
|
164 | (1) |
|
|
164 | (1) |
|
Spreading the Wealth across Files |
|
|
165 | (7) |
|
Knowing the Naming Conventions |
|
|
172 | (1) |
|
|
173 | (2) |
|
Chapter 7 Objects Objects Everywhere |
|
|
175 | (18) |
|
Replacing Numbers with Objects |
|
|
176 | (5) |
|
Revisiting the documentation |
|
|
178 | (2) |
|
Using an NSNumber as an argument |
|
|
180 | (1) |
|
Taking Advantage of Array Objects |
|
|
181 | (9) |
|
|
182 | (2) |
|
Tiptoeing through an array |
|
|
184 | (2) |
|
|
186 | (3) |
|
Working with fixed arrays |
|
|
189 | (1) |
|
|
190 | (3) |
|
Expanding to multidimensional arrays |
|
|
191 | (1) |
|
Finishing up with the main function |
|
|
192 | (1) |
|
Chapter 8 Using the Debugger |
|
|
193 | (18) |
|
Identifying the Usual Suspects |
|
|
193 | (7) |
|
|
194 | (2) |
|
Fixing it with Live Issues and Fix-It |
|
|
196 | (1) |
|
Crashing with runtime errors |
|
|
197 | (1) |
|
Dealing with logic errors |
|
|
198 | (2) |
|
|
200 | (4) |
|
|
204 | (3) |
|
Using the Static Analyzer |
|
|
207 | (4) |
|
Chapter 9 Using Control Statements and Loops |
|
|
211 | (22) |
|
Creating Transaction Objects |
|
|
212 | (4) |
|
Managing all those objects |
|
|
213 | (1) |
|
Adding the Transaction class |
|
|
213 | (3) |
|
|
216 | (4) |
|
Using Loop Statements to Repeat Instructions |
|
|
220 | (6) |
|
|
221 | (2) |
|
|
223 | (2) |
|
|
225 | (1) |
|
Adding Loops to Your Program |
|
|
226 | (3) |
|
Building the New Application |
|
|
229 | (1) |
|
Taking the Leap: Jump Statements |
|
|
230 | (1) |
|
Knowing the Problems with switch Statements |
|
|
231 | (2) |
|
Part III Walking the Object-Oriented Walk |
|
|
233 | (74) |
|
Chapter 10 Basic Inheritance |
|
|
235 | (20) |
|
Replacing a Control Structure with Polymorphism |
|
|
236 | (6) |
|
|
238 | (2) |
|
Knowing what inheritance enables you to do |
|
|
240 | (1) |
|
Using inheritance effectively |
|
|
241 | (1) |
|
Implementing Inheritance in a Program |
|
|
242 | (10) |
|
Creating the Transaction superclass |
|
|
242 | (3) |
|
Adding the files for the new subclasses |
|
|
245 | (1) |
|
Implementing the new subclasses |
|
|
246 | (2) |
|
Modifying main to use the new classes |
|
|
248 | (4) |
|
Considering Polymorphism and Inheritance |
|
|
252 | (3) |
|
Chapter 11 Encapsulating Objects |
|
|
255 | (20) |
|
Getting to Know the Model-View-Controller (MVC) Pattern |
|
|
255 | (2) |
|
Implementing the MVC Pattern |
|
|
257 | (3) |
|
|
258 | (1) |
|
|
259 | (1) |
|
|
260 | (3) |
|
Creating the Destination Class |
|
|
263 | (8) |
|
Designing the destination |
|
|
264 | (1) |
|
|
265 | (2) |
|
Modifying the Budget class |
|
|
267 | (2) |
|
Removing UI type functionality from the Transaction objects |
|
|
269 | (2) |
|
|
271 | (3) |
|
Yes, Another Two Steps Forward and One Step Back |
|
|
274 | (1) |
|
Chapter 12 The Birth of an Object |
|
|
275 | (14) |
|
|
275 | (1) |
|
|
276 | (11) |
|
Invoking the superclass's init method |
|
|
278 | (2) |
|
Initializing instance variables |
|
|
280 | (1) |
|
|
281 | (6) |
|
The Designated Initializer |
|
|
287 | (2) |
|
Chapter 13 Getting a Handle on Memory Management |
|
|
289 | (18) |
|
Raising and Terminating Responsible Objects |
|
|
290 | (2) |
|
Understanding the object life cycle |
|
|
291 | (1) |
|
Understanding Reference Counting |
|
|
292 | (4) |
|
Managing memory, retro-style |
|
|
292 | (4) |
|
|
296 | (4) |
|
Rule 1 Do not send retain, release, or autorelease messages to your objects |
|
|
297 | (1) |
|
Rule 2 Do not store pointers to Objective-C objects in C structures (structs) |
|
|
298 | (1) |
|
Rule 3 Inform the compiler about ownership when using Core Foundation-type objects |
|
|
299 | (1) |
|
Rule 4 Use the @autoreleasepool keyword |
|
|
299 | (1) |
|
Rule 5 Follow the naming conventions |
|
|
299 | (1) |
|
Converting Non-ARC Code to ARC |
|
|
300 | (7) |
|
Part IV Moving from Language to Application |
|
|
307 | (112) |
|
Chapter 14 Getting Data from Other Objects |
|
|
309 | (14) |
|
Getting Data from Objects |
|
|
309 | (2) |
|
Working with Declared Properties |
|
|
311 | (5) |
|
|
311 | (1) |
|
Implementing declared properties |
|
|
312 | (2) |
|
Accessing the instance variables from within the class |
|
|
314 | (2) |
|
Using Accessors to Get Data from Objects |
|
|
316 | (4) |
|
Properly Using Properties |
|
|
320 | (3) |
|
Chapter 15 Show Me the Data |
|
|
323 | (34) |
|
Understanding Application-Based Data |
|
|
323 | (3) |
|
|
324 | (1) |
|
Working with property lists |
|
|
325 | (1) |
|
|
326 | (3) |
|
Understanding a dictionary's keys and values |
|
|
326 | (1) |
|
|
327 | (2) |
|
Adding a plist to Your Project |
|
|
329 | (8) |
|
|
332 | (3) |
|
Creating a mutable dictionary |
|
|
335 | (1) |
|
Creating, initializing, and using the symbol string |
|
|
336 | (1) |
|
Dictionaries of Dictionaries |
|
|
337 | (8) |
|
Creating a more complex plist |
|
|
337 | (6) |
|
Managing a dictionary of dictionaries |
|
|
343 | (2) |
|
|
345 | (7) |
|
Adding a new entry to the plist |
|
|
345 | (2) |
|
|
347 | (5) |
|
Saving Data in a Separate File |
|
|
352 | (4) |
|
Saving Objects as Objects |
|
|
356 | (1) |
|
Chapter 16 Extending the Behavior of Objects |
|
|
357 | (16) |
|
|
358 | (1) |
|
|
359 | (7) |
|
|
359 | (1) |
|
|
360 | (1) |
|
Adding delegation to Transaction |
|
|
361 | (3) |
|
|
364 | (2) |
|
|
366 | (7) |
|
|
371 | (1) |
|
Defining informal protocols |
|
|
371 | (2) |
|
Chapter 17 Adding an iPhone User Interface |
|
|
373 | (30) |
|
|
374 | (2) |
|
Using Interface Builder to Create a User Interface |
|
|
376 | (9) |
|
Implementing the User Interface |
|
|
385 | (15) |
|
|
390 | (3) |
|
Connecting Targets with Actions |
|
|
393 | (4) |
|
|
397 | (3) |
|
Running iVacation in the Simulator |
|
|
400 | (1) |
|
|
401 | (2) |
|
Chapter 18 Adding a Mac User Interface |
|
|
403 | (16) |
|
|
403 | (3) |
|
Using Interface Builder to Create a User Interface |
|
|
406 | (3) |
|
Implementing the User Interface |
|
|
409 | (7) |
|
Using the Assistant Editor to add outlets and Targets-Actions |
|
|
411 | (4) |
|
|
415 | (1) |
|
Running mVacation on the Mac |
|
|
416 | (1) |
|
Knowing What's Left to Do |
|
|
417 | (1) |
|
|
417 | (2) |
|
|
419 | (12) |
|
Chapter 19 Ten Debugging Tips |
|
|
421 | (4) |
|
|
421 | (1) |
|
"Right" Is Not Always "right" |
|
|
422 | (1) |
|
When You've Blown It, You've Blown It |
|
|
422 | (1) |
|
Compiler Warnings Are for Your Own Good |
|
|
422 | (1) |
|
Get Friendly with Your Debugger |
|
|
422 | (1) |
|
|
423 | (1) |
|
|
423 | (1) |
|
|
423 | (1) |
|
|
424 | (1) |
|
|
424 | (1) |
|
Chapter 20 Ten Ways to Be a Happy Developer |
|
|
425 | (6) |
|
Keep Everyone in the Dark |
|
|
425 | (1) |
|
Make Your Code Easy to Understand |
|
|
426 | (1) |
|
|
426 | (1) |
|
Start by Initializing the Right Way |
|
|
427 | (1) |
|
Take Advantage of the Documentation |
|
|
427 | (1) |
|
|
427 | (1) |
|
Understand That Development Is Not Linear |
|
|
428 | (1) |
|
Do It Right from the Start If You Need to Do It Right from the Start |
|
|
428 | (1) |
|
Avoid the Code Slinger Mentality |
|
|
429 | (1) |
|
The Software Isn't Finished Until the Last User Is Dead |
|
|
429 | (1) |
|
|
430 | (1) |
Index |
|
431 | |