In the course of digging deep into the bowels of nib2cib to fix some bugs, I have become aware of a few issues that need to be addressed:
1. In initWithCoder:, it is *not* possible to reference other objects, because they may not yet be fully initialized and their internal state may be bogus or inconsistent. This problem is especially tricky to track down if initWithCoder: uses setter methods which reference or try to change the state of other objects. I have seen this problem manifest itself on occasion.
The solution is to defer initialization that references other objects to awakeAfterUsingCoder, at which time it is guaranteed that all referenced objects have been initialized and awakened.
2. It is essential that all encodeWithCoder methods take care to use encodeConditionalObject for weak references, otherwise there is a risk of including far more in the archive than is necessary to unarchive the object.
It would be good if we went through all of the CP and NS classes to check for this at some point.
Many thanks,
Aparajita
www.aparajitaworld.com
"If you dare to fail, you are bound to succeed."
- Sri Chinmoy | www.srichinmoy.org