On Fri, Aug 1, 2008 at 2:43 PM, Wayne Shao <[EMAIL PROTECTED]> wrote: > It seems that every object is a pointer in the sample code I have > seen. Is there any distinction between an object and its pointer?
Others have addressed the general concepts involved, but I wanted to answer this question specifically. There is a distinction between an object and its pointer, an important distinction. An object is a blob of memory with a certain layout. That layout is determined by the instance variables of the class, including all of its superclasses. The first item in the blob is always the 'isa' instance variable, which points to the object's class. This is how the runtime knows what kind of object you're dealing with, even when you pass things around as 'id'. The remaining items are the rest of the instance variables. A *pointer* to an object is just an address, like 0x12345678. This is the address of the first byte in that blob of memory. A pointer essentially lets you find that object in memory, but it is not the object. Think of it as the difference between your friend Bob, and your friend Bob's phone number. You can store Bob's phone number in every room of your house, but there remains only one Bob. If you then give Bob a present, the phone number in every room in the house will reach the Bob who is pleased because you gave him a present. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]