Im very confused with the memory management.
Declared variable allNoticeArray in .h file:
@interface NoticeViewController : UITableViewController
{
NSMutableArray *allNoticeArray;
}
@property (nonatomic, retain) NSMutableArray *allNoticeArray;
@end
Alloc and init the variable in .m file:
@implementation NoticeViewController
@synthesize allNoticeArray;
- (void)viewDidLoad
{
[super viewDidLoad];
self.allNoticeArray = [[[NSMutableArray alloc] init] autorelease];
}
- (void)dealloc
{
[super dealloc];
/*
***should I release allNoticeArray here or not?***
*/
//[allNoticeArray release];
}
Should I release the allNoticeArray in dealloc function or not?
Thank you in advance!
When not using ARC you should use the release in the dealloc. You are right in saying that your retain in the .h file increases the retain count by one. The Alloc/Init creates an object with a retain count of one. The auto release would counter that retain, however your dealloc release would count the retain in the .h.
Setting self.allNoticeArray=nil; is not the same as a release, but the link from sElan is a great link.