tags:

views:

94

answers:

1

I have the Array defined below.

NSMutableArray *tempMPArray = [NSMutableArray arrayWithCapacity:16];
for (int i=0; i < chapters; i++) 
{

   [tempMPArray addObject:[NSNull null]];
}

Every time I use it as a one of the objects of a dictionary below to register default values it crashes with EXC_BAD_ACCESS.

[[NSUserDefaults standardUserDefaults] registerDefaults:myDict];

If I replace the objects in the array with any other object NSNumber etc it works fine. What am I doing wrong with my array that NSUserDefaults rejects it ? The stack trace or NSZombie does not give any additional info.

A: 

Here's a better solution!

Define a static after @implementation

NSString *const Null = @"";

Then

NSMutableArray *tempDSArray = [NSMutableArray arrayWithCapacity:16];
 for (i=0; i < chapters; i++) 
 {

  [tempDSArray addObject:Null];
 }

Everything else should work fine!

Jordan
Jordan, thanks for saving my bacon. My thoughts got in a rut instead of thinking out of the box.
Roby