I have tried to use the Analyze instrument to see the memory leaks, and Xcode gives me a memory leak in this point:
.h
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
.m
@synthesize managedObjectContext = __managedObjectContext;
then in the code I do this:
AppDelegate *appController = [[UIApplication sharedApplication] delegate];
self.managedObjectContext = [[NSManagedObjectContext alloc] init];
[self.managedObjectContext setUndoManager:nil];
[self.managedObjectContext setPersistentStoreCoordinator: [appController persistentStoreCoordinator]];
and in the dealloc
this:
- (void)dealloc
{
[__managedObjectContext release];
[super dealloc];
}
It gives me a memory leak on this line:
[self.managedObjectContext setUndoManager:nil];
for this object:
self.managedObjectContext = [[NSManagedObjectContext alloc] init];
I have released it in the dealloc
, why a memory leak there?