Re: Determining whether a dictionary is mutable or not
Re: Determining whether a dictionary is mutable or not
- Subject: Re: Determining whether a dictionary is mutable or not
- From: Roland King <email@hidden>
- Date: Fri, 14 Jan 2011 19:36:35 +0800
On 14-Jan-2011, at 7:25 PM, Tito Ciuro wrote:
> Hi Mike,
>
> Given that the caller can pass a NSDictionary or an NSMutableDictionary, I wanted to test its mutability before calling setObject:forKey:. In order to avoid calling mutableCopy each time, I thought it would be more efficient to test it and then call mutableCopy only when needed.
>
> Thanks for the help,
>
> -- Tito
>
remember - write it first, optimize it later. If your app is slow and you run the performance tools on it and making mutable copies is what's causing you performance issues then by all means optimize it at that point. My suspicion would be that making mutable copies of existing dictionaries is a pretty fast operation, apple's pretty good at that stuff.
One other idea, if your method wants a dictionary it can mutate, how about making that the signature and making it up to the caller to send something mutable, as it seems not entirely unlikely the caller knows what it has.
_______________________________________________
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