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

How Things Work

We would be remiss if we finished this chapter without first tying a couple things together. Because the Objective-C language has the C language underneath, it’s worth mentioning some of the connections between the two. You can ignore these implementation details or use them to better understand how things work, in the same way that learning about pointers as memory addresses can help you better understand pointers. We don’t get too detailed here; we just state four facts about the relationship between Objective-C and C.

Fact #1: Instance Variables are Stored in Structures

When you define a new class and its instance variables, those instance variables are actually stored inside a structure. That’s how you can manipulate objects; they’re really structures whose members are your instance variables. So the inherited instance variables plus the ones you added in your class comprise a single structure. When you allocate a new object using alloc, enough space is reserved to hold one of these structures.


  

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