How to test for an uninitialized mutable array

39 Views Asked by At

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?

1

There are 1 best solutions below

0
Carl Carlson On

I used something like this:

NSString* name = [item.children className];
if ([name isEqualToString:   @"__NSPlaceholderArray" ])
{
    item.children = [[NSMutableArray alloc]init];
}
else...