For some weird reason golferStats is not storing info correctly…
I cut out a bunch of stuff in this code to the bare basics why is is still not working?
Problem: The last NSLOG returns nil when it should return a huge array…
NSMutableDictionary *golferStats = [[NSMutableDictionary alloc] init];
golferStats = [userDefaults objectForKey:@"golferStats"];
[golferStats setObject:golferTwoIconCounter forKey:golferName]; //golferName is k
[userDefaults setObject:golferStats forKey:@"golferStats"];
[userDefaults synchronize];
NSLog(@"SAVED SCORE CARD");
NSLog(@"%@",[golferStats objectForKey:@"k"]);
NSMutableDictionary *golferStats = [[NSMutableDictionary alloc] init];golferStats = [userDefaults objectForKey:@"golferStats"];…
[golferStats release];You first create an
NSDictionaryand then you assign over top of it, thus leaking memory and presumably gettingnilback from user defaults.setObject:forKey:in thenildictionary is a no-op, and then you are setting it back into the user defaults.EDIT:
Try checking if there is a dictionary first: