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 14. Getting Data from Other Objects

In This Chapter

  • Getting the data an object needs for another object

  • Understanding how declared properties work

  • Getting how the compiler synthesizes accessors

  • Recognizing the impact of declared properties to your program

  • Using accessors

  • Knowing the best way to use declared properties and accessors

In Chapter 11, you factor your code to create a Destination object that manages the other objects you needed in your model. You see how the Destination object can use other objects by sending them messages. While most of those messages are to get an object to do something (spendDollars:, for example), as you see when you implement returnBalance in Budget and leftToSpend in Destination, some of these messages are about data.

That data returned by those methods is stored as instance variables, but as you know, one object can't and shouldn't access another object's instance variables directly (hence, the need for those two methods). In this chapter, I will show you another way to get data from an object — declared properties — and I'll also tell you about some things you need to handle with care.

Getting Data from Objects

As I refine the Vacation application, I need to start thinking more about the practical aspects of using this application, especially as I march down the road toward putting on a user interface.

One thing that strikes me is that this whole exchange rate thing is not very robust. After all, the exchange rate changes often during the day, so ...

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