Before anyone says that its a question thats been asked many times before, i've gone through about 20 different answers and tried everything I found. Despite this, I only started objective c about 5 days ago, so there is probably some really simple solution.
It appears that NSUserDefaults does not load an array from the default property list, despite being called to in many different ways. Before i go on, here is my code for reading the array :
fishArrayMutable = [[NSMutableArray alloc] initWithArray:(NSArray*)[defaults objectForKey:@"fishArray"] copyItems:TRUE];
if (fishArrayMutable == nil)
{
fishArrayMutable = [[NSMutableArray alloc] init];
UIAlertView *alert = [[UIAlertView alloc] init];
[alert setTitle:@"fishArray = nil"];
[alert addButtonWithTitle:@"Ok"];
[alert show];
[alert release];
}
And here is my code for writing the array :
[defaults setObject:fishArrayMutable forKey:@"fishArray"];
[defaults synchronize];
This is starting to become a very frustrating problem now, and i've gone about ways of isolating the problem, and reached the conclusion that its in the reading part. The Mutable array is declared in the header file. Please help, this has been bugging me for about 6 hours now...
synchronizeis not necessary.