Re: NSMutableDictionary crashing?
Re: NSMutableDictionary crashing?
- Subject: Re: NSMutableDictionary crashing?
- From: Philippe Mougin <email@hidden>
- Date: Thu, 2 Jan 2003 12:32:00 +0100
It is perfectly possible to use this kind of parent-child relationship
in an NSDictionary. However, doing this creates a cycle in the object
graph, and some methods, like NSDictionarys -description, are not safe
in this situation.
In your case, you ask for the description of the parent dictionary.
Since the description of a dictionary contains the description of the
objects referenced by the dictionary, the -description method called on
the parent dictionary will itself call -description on the child
dictionary, which will itself call -description on the parent and son
on. We are stuck in an infinite recursion. At some point, memory is
exhausted and the application crashes.
This is a limitation of NSDictionarys -description method (BTW, the
same limitation exists for the other Cocoa collection classes) and it
should be documented as such. This is not a problem unique to Cocoa.
Most object-oriented frameworks (Java , Smalltalk) have the same
problem with their own description methods.
Best,
Phil
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.