I've written code to restore the state of my app, but there's a memory leak in the NSMutableArray. I'm new to Xcode so I apologize if this is something trivial I have overlooked. Any help is appreciated. lq
AppDelegate.m
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[rootViewController restoreState];
}
RootViewController.h
@interface rootViewController : UIViewController {
NSMutableArray *offendingNSMutableArray;
}
@property (nonatomic, retain) NSMutableArray *offendingNSMutableArray;
RootViewController.m
@synthesize offendingNSMutableArray;
- (void)restoreState {
// Gets an array stored in the user defaults plist
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
self.offendingNSMutableArray = [[NSMutableArray alloc]
initWithArray:[userDefaults objectForKey:kArrayValue]];
}
- (void)viewDidUnload {
self.offendingNSMutableArray = nil;
}
- (void)dealloc {
[offendingNSMutableArray release];
}