Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 5. Classes and Objects > Storing Data in Objects

Storing Data in Objects

In the previous task, you saw how to set up a method in an object. But objects can contain both methods and data. In this task, you’ll see how to store data in objects. You’ll also see how to pass arguments to object methods.

You set up your data in variables in the @interface section. Then your code can access those variables by name in the methods in the @implementation section. For example, the code here stores an integer:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial