• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSMutableDictionary crashing?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSMutableDictionary crashing?
      • From: Marcel Weiher <email@hidden>
  • Prev by Date: Re: straight-C DNS lookup with timeout?
  • Next by Date: Re: straight-C DNS lookup with timeout?
  • Previous by thread: NSMutableDictionary crashing?
  • Next by thread: Re: NSMutableDictionary crashing?
  • Index(es):
    • Date
    • Thread