Programming in Objective-C, Sixth Edition
Updated for OS X 10.9 Mavericks, iOS 7, and Xcode 5
Programming in Objective-C is a concise, carefully written tutorial on the basics of Objective-C and object-oriented programming for Apples iOS and OS X platforms.
Author(s): Stephan G. Kochan
Publisher: Addison-Wesley
Year: 2014
Language: English
Pages: 551
Table of Contents......Page 9
1 Introduction......Page 20
What You Will Learn from This Book......Page 21
How This Book Is Organized......Page 22
Acknowledgments......Page 24
Preface to the Sixth Edition......Page 25
Compiling and Running Programs......Page 26
Explanation of Your First Program......Page 37
Displaying the Values of Variables......Page 41
Exercises......Page 44
What Is an Object, Anyway?......Page 46
Instances and Methods......Page 47
An Objective-C Class for Working with Fractions......Page 49
The @interface Section......Page 52
The @implementation Section......Page 56
The program Section......Page 58
Accessing Instance Variables and Data Encapsulation......Page 64
Exercises......Page 68
Data Types and Constants......Page 70
Arithmetic Expressions......Page 74
Assignment Operators......Page 83
A Calculator Class......Page 84
Exercises......Page 86
5 Program Looping......Page 90
The for Statement......Page 91
The while Statement......Page 103
The do Statement......Page 108
Summary......Page 110
Exercises......Page 111
The if Statement......Page 112
The switch Statement......Page 134
Boolean Variables......Page 137
The Conditional Operator......Page 142
Exercises......Page 144
Separate Interface and Implementation Files......Page 146
Synthesized Accessor Methods......Page 152
Accessing Properties Using the Dot Operator......Page 154
Multiple Arguments to Methods......Page 156
Local Variables......Page 162
The self Keyword......Page 167
Allocating and Returning Objects from Methods......Page 168
Exercises......Page 170
It All Begins at the Root......Page 172
Extension through Inheritance: Adding New Methods......Page 177
Overriding Methods......Page 190
Exercises......Page 195
Polymorphism: Same Name, Different Class......Page 198
Dynamic Binding and the id Type......Page 201
Compile Time Versus Runtime Checking......Page 203
The id Data Type and Static Typing......Page 204
Asking Questions about Classes......Page 206
Exception Handling Using @try......Page 211
Exercises......Page 214
Initializing Objects......Page 216
Scope Revisited......Page 219
Enumerated Data Types......Page 226
The typedef Statement......Page 229
Data Type Conversions......Page 230
Bit Operators......Page 232
Exercises......Page 239
Categories......Page 242
Class Extensions......Page 247
Protocols and Delegation......Page 249
Composite Objects......Page 253
Exercises......Page 254
The #define Statement......Page 256
The #import Statement......Page 263
Conditional Compilation......Page 264
Exercises......Page 268
13 Underlying C Language Features......Page 270
Arrays......Page 271
Functions......Page 277
Blocks......Page 285
Structures......Page 289
Pointers......Page 296
Miscellaneous Language Features......Page 316
How Things Work......Page 321
Exercises......Page 323
Foundation Documentation......Page 326
Number Objects......Page 330
String Objects......Page 336
Array Objects......Page 352
Dictionary Objects......Page 381
Set Objects......Page 386
Exercises......Page 392
16 Working with Files......Page 396
Managing Files and Directories: NSFileManager......Page 397
Working with Paths: NSPathUtilities.h......Page 408
Basic File Operations: NSFileHandle......Page 417
The NSURL Class......Page 422
The NSBundle Class......Page 423
Exercises......Page 424
17 Memory Management and Automatic Reference Counting......Page 426
Manual Reference Counting......Page 428
The Event Loop and Memory Allocation......Page 431
Summary of Manual Memory Management Rules......Page 433
Strong Variables......Page 434
Weak Variables......Page 435
@autoreleasepool Blocks......Page 436
Method Names and Non-ARC Compiled Code......Page 437
The copy and mutableCopy Methods......Page 438
Shallow Versus Deep Copying......Page 441
Implementing the Protocol......Page 443
Copying Objects in Setter and Getter Methods......Page 446
Exercises......Page 448
Archiving with XML Property Lists......Page 450
Archiving with NSKeyedArchiver......Page 453
Writing Encoding and Decoding Methods......Page 454
Using NSData to Create Custom Archives......Page 461
Using the Archiver to Copy Objects......Page 465
Exercises......Page 466
Framework Layers......Page 468
Cocoa Touch......Page 469
Your First iPhone Application......Page 472
An iPhone Fraction Calculator......Page 488
Summary......Page 502
Exercises......Page 503
A: Glossary......Page 504
B: Address Book Example Source Code......Page 512
Index......Page 518
A......Page 519
B......Page 521
C......Page 522
D......Page 526
F......Page 528
H......Page 532
I......Page 533
L......Page 535
M......Page 536
N......Page 541
O......Page 542
P......Page 544
R......Page 545
S......Page 546
U......Page 549
X-Y-Z......Page 550