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 <carterharri...@mac.com>:
>
> 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 (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/middle.fengdong%40gmail.com
>
> This email sent to middle.fengd...@gmail.com
>
_______________________________________________

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 arch...@mail-archive.com

Reply via email to