Brain Candy Sale

Special Offers see all

Enter to WIN a $100 Credit

Subscribe to
for a chance to win.
Privacy Policy

Visit our stores

    Recently Viewed clear list

    Lists | October 5, 2015

    Zachary Thomas Dodson: IMG 10 Books That Will Change Your Mind about Bats

    Bats are a much-maligned animal. Long thought of as creepy or evil or diseased, a closer look reveals that the wide variety of bat species also... Continue »
    1. $19.57 Sale Hardcover add to wish list


This item may be
out of stock.

Click on the button below to search for this title in other formats.

Check for Availability
Add to Wishlist

Programming in Objective-C


Programming in Objective-C Cover


Synopses & Reviews

Publisher Comments:

This is the eBook version of the printed book.

Updated for iOS 5 and ARC

An introduction to the Objective-C language for iOS and Mac OS X development

Objective-C has become the standard programming language for application development on the iOS and Mac OS X platforms. A powerful yet simple object-oriented programming language that’s based on C, Objective-C is widely available not only on Apple platforms but across many operating systems, including Linux, Unix, and Windows.

Programming in Objective-C provides the new programmer a complete, step-by-step introduction to the Objective-C language. The book does not assume previous experience with either C or object-oriented

programming languages, and it includes many detailed, practical examples of how to put Objective-C to use in your everyday programming needs.

The fourth edition of this book has been updated to cover the significant changes that first appeared in iOS 5 and Xcode 4.2, including the use of Automatic Reference Counting (ARC) to improve and simplify memory management in Objective-C programs.

It also shows how to take advantage of the Foundation framework’s rich built-in library of classes and provides an introduction to iOS programming.

“The best book on any programming language that I’ve ever read. If you want to learn Objective-C, buy it.”  —Calvin Wolcott

“An excellent resource for a new programmer who wants to learn Objective-C as their first programming language—a woefully underserved market.”  —Pat Hughes

Stephen G. Kochan is author or coauthor of several bestselling books on the C language, including Programming in C, Programming in ANSI C, and Topics in C Programming. He has written extensively on Unix and is the author of Exploring the Unix System and Unix Shell Programming. Kochan has been programming Macintosh computers since the introduction of the first Mac in 1984 and wrote Programming C for the Mac for the Apple Press Library as well as Beginning AppleScript.

About the Author

Stephen Kochan is the author and coauthor of several bestselling titles on the C language, including Programming in C (Sams, 2004), Programming in ANSI C (Sams, 1994), and Topics in C Programming (Wiley, 1991), and several Unix titles, including Exploring the Unix System (Sams, 1992) and Unix Shell Programming (Sams, 2003). He has been programming on Macintosh computers since the introduction of the first Mac in 1984, and he wrote Programming C for the Mac as part of the Apple Press Library. In 2003 Kochan wrote Programming in Objective-C (Sams, 2003), and followed that with another Mac-related title, Beginning AppleScript (Wiley, 2004).

Table of Contents

1 Introduction 1

What You Will Learn from This Book 2

How This Book Is Organized 3

Support 5

Acknowledgments 5

Preface to the Fourth Edition 6

2 Programming in Objective-C 7

Compiling and Running Programs 7

Using Xcode 8

Using Terminal 17

Explanation of Your First Program 19

Displaying the Values of Variables 23

Summary 25

Exercises 25

3 Classes, Objects, and Methods 27

What Is an Object, Anyway? 27

Instances and Methods 28

An Objective-C Class for Working with Fractions 30

The @interface Section 33

Choosing Names 34

Class and Instance Methods 35

The @implementation Section 37

The program Section 39

Accessing Instance Variables and Data Encapsulation 45

Summary 49

Exercises 49

4 Data Types and Expressions 51

Data Types and Constants 51

Type int 51

Type float 52

Type char 52

Qualifiers: long, long long, short, unsigned, and signed 53

Type id 54

Arithmetic Expressions 55

Operator Precedence 55

Integer Arithmetic and the Unary Minus Operator 58

The Modulus Operator 60

Integer and Floating-Point Conversions 61

The Type Cast Operator 63

Assignment Operators 64

A Calculator Class 65

Exercises 67

5 Program Looping 71

The for Statement 72

Keyboard Input 79

Nested for Loops 81

for Loop Variants 83

The while Statement 84

The do Statement 88

The break Statement 90

The continue Statement 90

Summary 91

Exercises 91

6 Making Decisions 93

The if Statement 93

The if-else Construct 98

Compound Relational Tests 100

Nested if Statements 103

The else if Construct 105

The switch Statement 114

Boolean Variables 117

The Conditional Operator 122

Exercises 124

7 More on Classes 127

Separate Interface and Implementation Files 127

Synthesized Accessor Methods 132

Accessing Properties Using the Dot Operator 134

Multiple Arguments to Methods 135

Methods Without Argument Names 137

Operations on Fractions 137

Local Variables 140

Method Arguments 141

The static Keyword 141

The self Keyword 145

Allocating and Returning Objects from Methods 146

Extending Class Definitions and the Interface File 148

Exercises 148

8 Inheritance 151

It All Begins at the Root 151

Finding the Right Method 155

Extension Through Inheritance: Adding New Methods 156

A Point Class and Object Allocation 160

The @class Directive 161

Classes Owning Their Objects 165

Overriding Methods 169

Which Method Is Selected? 171

Abstract Classes 173

Exercises 174

9 Polymorphism, Dynamic Typing, and Dynamic Binding 177

Polymorphism: Same Name, Different Class 177

Dynamic Binding and the id Type 180

Compile Time Versus Runtime Checking 182

The id Data Type and Static Typing 183

Argument and Return Types with Dynamic Typing 184

Asking Questions About Classes 185

Exception Handling Using @try 189

Exercises 192

10 More on Variables and Data Types 195

Initializing Objects 195

Scope Revisited 198

Directives for Controlling Instance Variable Scope 198

More on Properties, Synthesized Accessors, and Instance Variables 200

Global Variables 200

Static Variables 202

Enumerated Data Types 205

The typedef Statement 208

Data Type Conversions 209

Conversion Rules 210

Bit Operators 211

The Bitwise AND Operator 212

The Bitwise Inclusive-OR Operator 213

The Bitwise Exclusive-OR Operator 214

The Ones Complement Operator 214

The Left Shift Operator 216

The Right Shift Operator 216

Exercises 217

11 Categories and Protocols 219

Categories 219

Class Extensions 224

Some Notes About Categories 225

Protocols and Delegation 226

Delegation 229

Informal Protocols 229

Composite Objects 230

Exercises 231

12 The Preprocessor 233

The #define Statement 233

More Advanced Types of Definitions 235

The #import Statement 240

Conditional Compilation 241

The #ifdef, #endif, #else 241

The #if and #elif Preprocessor Statements 243

The #undef Statement 244

Exercises 245

13 Underlying C Language Features 247

Arrays 248

Initializing Array Elements 250

Character Arrays 251

Multidimensional Arrays 252

Functions 254

Arguments and Local Variables 255

Returning Function Results 257

Functions, Methods, and Arrays 261

Blocks 262

Structures 266

Initializing Structures 269

Structures Within Structures 270

Additional Details About Structures 272

Don’t Forget About Object-Oriented Programming! 273

Pointers 273

Pointers and Structures 277

Pointers, Methods, and Functions 279

Pointers and Arrays 280

Constant Character Strings and Pointers 286

Operations on Pointers 290

Pointers and Memory Addresses 292

They’re Not Objects! 293

Miscellaneous Language Features 293

Compound Literals 293

The goto Statement 294

The null Statement 294

The Comma Operator 294

The sizeof Operator 295

Command-Line Arguments 296

How Things Work 298

Fact #1: Instance Variables Are Stored in Structures 298

Fact #2: An Object Variable Is Really a Pointer 299

Fact #3: Methods Are Functions, and Message

Expressions Are Function Calls 299

Fact #4: The id Type Is a Generic Pointer Type 299

Exercises 300

14 Introduction to the Foundation Framework 303

Foundation Documentation 303

15 Numbers, Strings, and Collections 307

Number Objects 307

String Objects 312

More on the NSLog Function 312

The description Method 313

Mutable Versus Immutable Objects 314

Mutable Strings 320

Array Objects 327

Making an Address Book 330

Sorting Arrays 347

Dictionary Objects 354

Enumerating a Dictionary 355

Set Objects 358

NSIndexSet 362

Exercises 365

16 Working with Files 369

Managing Files and Directories: NSFileManager 370

Working with the NSData Class 375

Working with Directories 376

Enumerating the Contents of a Directory 379

Working with Paths: NSPathUtilities.h 381

Common Methods for Working with Paths 383

Copying Files and Using the NSProcessInfo Class 386

Basic File Operations: NSFileHandle 390

The NSURL Class 395

The NSBundle Class 396

Exercises 397

17 Memory Management and Automatic Reference Counting 399

Automatic Garbage Collection 401

Manual Reference Counting 402

Object References and the Autorelease Pool 403

The Event Loop and Memory Allocation 405

Summary of Manual Memory Management Rules 407

Automatic Reference Counting (ARC) 408

Strong Variables 408

Weak Variables 409

@autoreleasepool Blocks 410

Method Names and Non-ARC Compiled Code 411

18 Copying Objects 413

The copy and mutableCopy Methods 413

Shallow Versus Deep Copying 416

Implementing the Protocol 418

Copying Objects in Setter and Getter Methods 421

Exercises 423

19 Archiving 425

Archiving with XML Property Lists 425

Archiving with NSKeyedArchiver 427

Writing Encoding and Decoding Methods 429

Using NSData to Create Custom Archives 436

Using the Archiver to Copy Objects 439

Exercises 441

20 Introduction to Cocoa and Cocoa Touch 443

Framework Layers 443

Cocoa Touch 444

21 Writing iOS Applications 447

The iOS SDK 447

Your First iPhone Application 447

Creating a New iPhone Application Project 449

Entering Your Code 452

Designing the Interface 455

An iPhone Fraction Calculator 461

Starting the New Fraction_Calculator Project 462

Defining the View Controller 464

The Fraction Class 469

A Calculator Class That Deals with Fractions 473

Designing the UI 474

Summary 475

Exercises 476

A Glossary 479

B Address Book Example Source Code 487

TOC, 9780321911905, 11/28/2011

Product Details

Addison-Wesley Professional
Computers : Programming Languages - C
Kochan, Stephen G.
Publication Date:
December 2011

Related Subjects

Computers and Internet » Computer Languages » C
Computers and Internet » Programming » Apple Programming
Computers and Internet » Software Engineering » Programming and Languages

Programming in Objective-C
0 stars - 0 reviews
$ In Stock
Product details 499 pages Pearson Education - English 9780132900898 Reviews:
  • back to top


Powell's City of Books is an independent bookstore in Portland, Oregon, that fills a whole city block with more than a million new, used, and out of print books. Shop those shelves — plus literally millions more books, DVDs, and gifts — here at