Re: NSDictionary question
Re: NSDictionary question
- Subject: Re: NSDictionary question
- From: Olivier <email@hidden>
- Date: Fri, 15 Nov 2002 08:58:29 -0600
The object that are in the key array are copied and the object that are
in the object array are retained.
ObjectForKey: return a reference.
Olivier
On Thursday, November 14, 2002, at 12:58 AM, Hisaoki Nishida wrote:
In the instance method description of initWithObjects:forKeys: in
NSDictionary:
Initializes a newly allocated dictionary with entries constructed from
the contents of the objects and keys arrays. This method steps through
the objects and keys arrays, creating entries in the new dictionary as
it goes. Each value object receives a retain message before being added
to the dictionary. In contrast, each key object is copied (using
copyWithZone:), and the copy is added to the dictionary. An
NSInvalidArgumentException is raised if the objects and keys arrays do
not have the same number of elements.
It says that value objects are retained while key objects are copied.
How do I know if the object I am adding is a value or a key object?
I know NSNumber for example is a value object, but what makes it
different from an object I create that wraps a number. It's still
conceptually a short-lived value object. How does it know it is a value
object?
Also, in a related matter, just to be sure I want to ask if
objectForKey: instance method returns a copy or a reference.
Thank you.
-Yuki
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.