0

I have corrupted a single object in a file. When I load in the file, one of my mutable arrays (1) contains another mutable array (2) (loaded from the same file) which is uninitialized. When I try to examine the array (2) with a for-in loop, I get: -[NSMutableArray count]: method sent to an uninitialized mutable array object"

I can get away with deleting array (2), but how do I test for it?

2
  • How do you load the file? Commented Jul 16, 2022 at 7:42
  • 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 think the problem object was damaged before I archived the data. Commented Jul 16, 2022 at 18:23

1 Answer 1

0

I used something like this:

NSString* name = [item.children className];
if ([name isEqualToString:   @"__NSPlaceholderArray" ])
{
    item.children = [[NSMutableArray alloc]init];
}
else...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.