How to detect an uninitialized NSMutableArray produced by NSKeyedUnarchiver.unarchiveObjectWithData

Using NSDocument.readFromData and NSKeyedUnarchiver.unarchiveObjectWithData, I retrieve an object (of type A) with a property of type NSMutableArray. That array contains a nested chain of objects of type A. The problem object is a child of a child... in that array. I try to do Count on that array and I get an error.

Replies

Can you post some code snippets that show what you're actually doing inside type A?

Note that if you have a chain of references to other A instances, you might see some of them after they're allocated, but before they're fully initialized. You will need to be very careful about what members (properties, functions) of A you use while the unarchiving is still in progress.

  • Polyphonic: Thank you for your prompt reply. It caused me to think more deeply about the issue. I have other obligations right now. I'll comment substantively tomorrow after I have thought more on the issue.

  • I am loading the archived data for a NSOutlineView. My OutlineItems are stored in a tree. Each OutlineItem contains a NSMutableArray (Children). This array contains the children for that OutlineItem. The problem turns out to be with one OutlineItem. Its Children' is shown as an __NSPlaceholderArray when I debug. Apparently it was archived that way due to a bug. Right now, I'm looking for a way to detect items with such an array and delete the item. I'll save the bug itself for later.

Add a Comment