Re: Question Regarding the Memory Address of Objects
Re: Question Regarding the Memory Address of Objects
- Subject: Re: Question Regarding the Memory Address of Objects
- From: "Dong Feng" <email@hidden>
- Date: Sat, 20 Dec 2008 19:50:41 +0800
I have a concern that the direct use of a pointer as a memory address
may have a problem in the case of GC. In Java, object reference is not
a simple memory address because objects may be moved by GC. Does Cocoa
has a GC implementation avoid it?
2008/12/19 Carter R. Harrison <email@hidden>:
>
> On Dec 18, 2008, at 3:44 PM, David Duncan wrote:
>
>> On Dec 18, 2008, at 11:57 AM, Carter R. Harrison wrote:
>>
>>> [dict setValue:@"button1" forKey:[NSString stringWithFormat:@"%x",
>>> &button1]]; // "button1" is one of my IBOutlets.
>>> NSString *value = [dict valueForKey:[NSString
>>> stringWithFormat:@"%x", &sender]];
>>>
>>> It seems like the memory address of the sender is different than what it
>>> should be. I did some debugging and the address of the sender is always
>>> bfffe2e8 which really shouldn't be possible at all.
>>
>>
>> Your confusing the pointer with the object itself. button1 is a pointer to
>> a button. sender is a pointer to the object that sent the message. When you
>> take the address of either pointer, you get the location of that pointer in
>> memory - not the location of the object. The pointer itself contains the
>> location of the object in memory.
>> --
>> David Duncan
>> Apple DTS Animation and Printing
>>
>
> David,
>
> Once again you have saved me from pulling my hair out. Thank you once again
> for your assistance. For the rest of the folks on the thread the solution
> was to remove the "&" from the front of all my pointers.
>
> Regards,
> Carter
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden