NSDictionary question
NSDictionary question
- Subject: NSDictionary question
- From: Hisaoki Nishida <email@hidden>
- Date: Thu, 14 Nov 2002 01:58:13 -0500
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.