Skip to Main Content
Objective-C® For Dummies®
book

Objective-C® For Dummies®

by Neal Goldstein
October 2009
Beginner content levelBeginner
456 pages
8h 59m
English
For Dummies
Content preview from Objective-C® For Dummies®

Chapter 6. Adding a Little More Class to Your Program

In This Chapter

  • Understanding objects and classes

  • Dissecting an object-oriented program

  • Defining the program interface

  • Implementing the interface

  • Examining the program logic

  • Using more than one source file

  • Getting the naming conventions

This chapter covers objects and classes and messages, and the difference between a program based on functions and global data and one based on objects. I show you quite a bit about the mechanics of using objects and classes in your program.

I also introduce you to some basic ideas about encapsulation. Encapsulation involves more than simply hiding instance variables behind the object's wall, as you'll see as you read this chapter and the rest of this book.

I also explain and illustrate some of the advantages of using objects, but to be frank, I only scratch the surface when it comes to that. As you continue through this book, I'll illustrate, and you'll discover on your own, many more.

Grasping Objects and Their Classes

In Chapter 5, I showed you what you would have to do to make your program easier to extend. You created two functions, spendDollars: and chargeForeignCurrnecy:, that used a pointer to a budget variable. You could then pass in the pointer to europeBudget or englandBudget depending on where you were (Europe or England), and the function would operate on the data for that country.

The program architecture you created looked like the following (I'm going to omit the function implementation for ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Objective-C

Objective-C

Jiva DeVoe
Cocoa in a Nutshell

Cocoa in a Nutshell

Michael Beam, James Duncan Davidson

Publisher Resources

ISBN: 9780470522752Purchase book