gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableDictionary requires NSCopying?


From: Matt Rice
Subject: Re: NSMutableDictionary requires NSCopying?
Date: Mon, 19 Mar 2007 07:59:13 -0700
User-agent: GNUMail (Version 1.2.0)

On 2007-03-19 02:43:36 -0800 Richard Frith-Macdonald <address@hidden> wrote:


On 19 Mar 2007, at 10:24, Michael Gardner wrote:

To use a custom key type with NSMutableDictionary, I defined -hash and -isEqual: but not -copyWithZone:, since the NSDictionary docs say that
keys are retained rather than copied. But when I try to insert a key
of that type, I get an NSInvalidArgumentException saying that my class does not recognize -copyWithZone:. If I add that method, the exception
goes away and everything works fine. I've tried this on both the
latest GNUstep release and on trunk. Are the docs just out-of-date?

Yes, the documentation is just wrong. Dictionary keys do need to be copied.

I've fixed the documentation (at least, all the errors I spotted) in svn trunk to say that keys are copied.


possibly worthwile to explain why things are copied and not retained,
if you add a mutable object to a dictionary and subsequently modify the object in a way which modifies the objects -hash value, it would become inconsistent
with the hash value stored in the dictionary.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]