开发者

NSDictionary objectForKey answere randomly

I have a NSMutableDictionary, and my keys are objects (and the class implement the NSCopying protocol).

I add a value in 开发者_StackOverflow中文版the dictionary associated to a key, then, when I call the objectFoKey: method for the key which is in the dictionary, randomly, sometimes the method call "isEqual" and the key is found, and sometimes, the method "isEqual" is not called and the key is not found.

I can understand I do something wrong and the key is not found, but why sometimes the key is found but not always ?

Thank you very much if you have some hints to fix that problem, it becomes to make me crazy.


Oups, ok, I found my mistake:

I must implement the hash method, that I didn't do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜