Amazon.com Widgets Program 9.2
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 20, 2014, 07:33:29 PM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Chapter Study
| | |-+ Chapter 9 - Polymorphism, Dynamic Typing, and Dynamic Binding
| | | |-+ Program 9.2
Pages: [1] Go Down
Print
Author Topic: Program 9.2 (Read 1624 times)
wellaged37
Newbie
*
Posts: 39






on: April 14, 2009, 08:47:51 AM

Re: The id data type and dataValue.

1. Is it correct to say that dataValue is not a pointer?
2. Is it correct to say that dataValue is the memory location of the object?
3. Is it correct to say that the runtime system accesses the memory location of the object to determine its class?
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #1 on: April 14, 2009, 09:07:15 AM

1. Is it correct to say that dataValue is not a pointer?  No, it is a pointer.
2. Is it correct to say that dataValue is the memory location of the object?  Yes -- which is what makes it a pointer
3. Is it correct to say that the runtime system accesses the memory location of the object to determine its class? Yes.

Steve
Logged
wellaged37
Newbie
*
Posts: 39






Reply #2 on: April 14, 2009, 01:58:53 PM

Since it is a pointer then why doesn't dataValue (or id) have an asterisk?
Doesn't a pointer have its own memory address and the value it holds at that memory address is the address of an object?  I know you made a point of the fact, in the book, that dataValue doesn't have an asterisk but I wondered why it doesn't.
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #3 on: April 14, 2009, 02:25:57 PM

Since it is a pointer then why doesn't dataValue (or id) have an asterisk?
Doesn't a pointer have its own memory address and the value it holds at that memory address is the address of an object?  I know you made a point of the fact, in the book, that dataValue doesn't have an asterisk but I wondered why it doesn't.

I was afraid you would ask that question!    Shocked

The asterisk is "hidden" by the way id is defined.  It's actually a typedef (described in Chapter 10--see the example of NumberObject on page 219) that looks like this:

Code: (Objective-C)
typedef struct objc_object { 
    Class isa;
} *id;

Without getting into too much detail, id is defined here as a pointer to an objc_object structure (described in Chapter 12).   Let's leave it at that for now!    Smiley

Cheers,

Steve Kochan
Logged
wellaged37
Newbie
*
Posts: 39






Reply #4 on: April 14, 2009, 02:31:24 PM

Thanks Steve. I will leave it at that.
John
Logged
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.