Re: 4.5 question - _holdMe array trick
Re: 4.5 question - _holdMe array trick
- Subject: Re: 4.5 question - _holdMe array trick
- From: Art Isbell <email@hidden>
- Date: Thu, 21 Aug 2003 10:31:36 -1000
On Thursday, August 21, 2003, at 10:03 AM, Robert A. Decker wrote:
We've found that if we occasionally have a problem with something being
collected out from underneath us, the problem is solved by sticking the
item in an NSArray. I assume this is a bridge issue.
You didn't directly state that you are coding in Java, but I assume so
because the Java-ObjC bridge isn't involved if you code in ObjC.
More likely the Java object's last reference was removed which results
in the bridge releasing the corresponding ObjC object. This is correct
bridge behavior.
Does anyone know if you can get the same fix with an NSDictionary?
The Java NSDictionary class description states:
"Methods that add entries to dictionarieswhether during construction
(for all dictionaries) or modification (for mutable dictionaries)add
each value object to the dictionary directly, but copy each key
argument and add the copy to the dictionary."
Although this doesn't state explicitly that a strong reference to the
value is made, the ObjC NSDictionary class description makes this clear:
"Methods that add entries to dictionarieswhether as part of
initialization (for all dictionaries) or during modification (for
mutable dictionaries)copy each key argument (keys must conform to the
NSCopying protocol) and add the copies to the dictionary. Each
corresponding value object receives a retain message to ensure that it
wont be deallocated before the dictionary is through with it."
So including the object as a dictionary key won't prevent it from
being garbage-collected as would including it as a dictionary value.
Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.