I've some doubts regarding dealloc function in iPhone program. Is it required to give [self.object_name release] or [object_name release] is ok?.. I've this strange problem in my dealloc function is like this.
-(void) dealloc {
[self.listOfDates release];
[self.listOfDescriptions release];
[super dealloc];
}
But program crashes giving EXEC_BAD_ACCESS. Here both objects are NSMutableArray instances allocated with alloc in init function for the class. The same function without self works fine i.e
-(void) dealloc {
[listOfDates release];
[listOfDescription release];
[super dealloc];
}
Here is how I declared the property
@property (nonatomic,retain) NSMutableArray *listOfDates;
@property (nonatomic,retain) NSMutableArray *listOfDescription;
In the implementation file I sysnthesized this and inside the init function I've allocated these variables like this
self.listOfDates = [[NSMutableArray alloc] init];
self.listOfDescription = [[NSMutableArray alloc] init];
So is it required to give self ? What am I missing here?
Issue resolved when I removed mutableCopy function which I had used to copy instance of NSMutableArrays which were passed as argument to the init function as shown below
-(id)initWithDate:(NSMutableArray *)dates andDescription:(NSMutableArray*)descriptions
{
if(self = [super initWithNibName:@"DateDescriptionControl" bundle:nil])
{
self.listOfDates = [[NSMutableArray alloc] init];
self.listOfDescription = [[NSMutableArray alloc] init];
self.listOfDates = [dates mutableCopy];
self.listOfDescription = [description mutableCopy];
}
return self;
}
After removing the mutableCopy the dealloc is now not throwing EXEC_BAD_ACCESS. So where have I made the mistake I still can't figure out :(