I have the following 2 code snippets. Suppose I have a parent class, and in the Parent.h class I have
@property (retain) NSMutableArray *childrens;
and I synthesized it correctly in the .m file. suppose in the file Parent.m
- (void) dealloc
{
[childrens release]; [super dealloc];
}
In another class, I declare the following:
1.
Parent *p = [[Parent alloc] init]; p.chidlrens = [[NSMutableArray alloc] init];
2.
Parent *p = [[Parent alloc] init]; NSMutableArray *childArray = [[NSMutableArray alloc] init]; p.childrens = childArray; [childArray release];
From the above 2 methods, is there a leak in method 1?
source share