How to solve the leaks when allocating the NSMutableArray in Objective-C
- by Madan Mohan
Hi Guys,
I am getting leaks in Master view controller of iPhone.
When I call this method, I am inserting them into filteredListCount array, because when I search I need to show the list from filteredListCount array otherwise customerArray.
This functionality is working fine but I am getting leaks in the method below at allocation: filteredListCount = [[NSMutableArray alloc] initWithCapacity: [customerArray count]];
This is the first view controller of my application, I am showing the list and I am also allowing to search from a list.
- (void)parser:(CustomerListLibXmlParser *)parser addCustomerObject:(Customer *)customerObj1
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[customerArray addObject:customerObj1];
filteredListCount = [[NSMutableArray alloc] initWithCapacity: [customerArray count]];
[filteredListCount addObjectsFromArray: customerArray];
[theTableView reloadData];
}
- (void)parser:(CustomerListLibXmlParser *)parser encounteredError:(NSError *)error
{
}
- (void)parserFinished:(CustomerListLibXmlParser *)parser
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
self.title=@"Customers";
}