Re: Copying id
Re: Copying id
- Subject: Re: Copying id
- From: Charles Srstka <email@hidden>
- Date: Mon, 11 Aug 2008 21:26:59 -0500
On Aug 11, 2008, at 9:15 PM, Mike wrote:
Because, I have a case where I need to create my own object for
storing key/value pairs in a sorted array. Since NSDictionary, etc.
doesn't allow sorted elements in the dictionary, I have to define my
own - but in an array instead of a dictionary.
Both the key and value for each key in the items in my array can be
of any object type (id). The sorted key/value paid array class has
to be able to make copies of the items in the arrays when it goes to
sort them. Since the array class has to be generic to work with any
kind of key, and any kind of object, I can't know the types
beforehand. Since the array lass is generic and has to work for any
objects, I can't assume that the objects implement NSCopying.
You could check at runtime whether the object supports NSCopying, and
make a copy if it does, and just retain it otherwise. Would that work
for you?
Charles
_______________________________________________
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