It is explained by an Apple engineer on the Apple Mailing List: http://lists.apple.com/archives/cocoa-dev/2007/May/msg00747.html,
in reply to a similar question about archiving an NSMutableArray
containing itself as an element.
Summary:
This (very probably -- I haven't looked into it) is not a problem with the recursion per-se, but rather with objects which replace themselves during unarchiving by returning a new object from
initWithCoder:
.
...
So the summary answer is: you can't reliably have recursive references. In practice, though, these do occur (think of theNSView
subview/superview relationship) and things squeak by. Sometimes they don't and it's impossible to know beforehand if something will work or not.Chris Kane
Cocoa Frameworks, Apple