I have a property declared like this:
@property (nonatomic, retain) NSMutableArray *pricingLevels;
And I assign it like this:
self.pricingLevels
is a property declared as retained
which means every time you set it thru property assignment (the dot-syntax OR the method), the object automatically retains the object for you.
self.pricingLevels = [NSMutableArray array];
[self setPricingLevels:[NSMutableArray array]];
The above code will do the same and automatically retain the array passed. This is what happens under the hood (or something similar). This method gets called:
- (void)setPricingLevels:(NSMutableArray *)a {
if(_pricingLevels != a) {
[_pricingLevels release];
_pricingLevels = [a retain];
}
}
You see? Automatically retained, while the previous value automatically gets released.
EDIT to answer your last question: Yes you should call autorelease