Difference in NSMutableArray declaration
What is the diffe开发者_如何转开发rence between [NSMutableArray array]
and [[NSMutableArray alloc] init]
?
[NSMutableArray array]
is equivalent to [[[NSMutableArray alloc] init] autorelease]
.
[NSMutableArray array]
returns an autoreleased array.
[[NSMutableArray alloc] init]
returns a retained array.
You don't own the autoreleased array, so you don't have to release it. You own the retained one (with alloc), so you have to release it.
精彩评论