On Jan 14, 2011, at 7:57 AM, Roland King wrote:
> Again let me say that if the signature to your method is
>
> -(void)doSomethingWithADictionary:(NSDictionary*)dictionary;
>
> you shouldn't be trying to figure out whether that dictionary is mutable and
> mutate it.
Yup.
> If you want it to be otherwise make the signature
>
>
> -(void)doSomethingWithADictionaryICanReallyMessUpForYou:(NSMutableDictionary*)dictionary
>
> and make all the callers send mutable objects they know they don't need later
> and which they are forewarned you may be messing about with.
I suggest letting the caller tell you what kind of dictionary it is sending.
Have two different methods:
-(void)doSomethingWithADictionary:(NSDictionary*)dictionary;
-(void)doSomethingWithAMutableDictionary:(NSMutableDictionary*)dictionary;
Have each of these call a private method that does the real work:
-(void)_privatelyDoSomethingWithAPossiblyMutableDictionary:(id)dictionary
mutable:(BOOL)isMutable;
Instead of trying to test the dictionary object for mutability (which won't
work), simply check isMutable.
--Andy
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]