I started working with tools and had a lot of leaks. I have no idea how to solve them.
The tool shows that I have a leak in this line:
NSArray *topLevelObjects = [[NSArray alloc] initWithArray:[[NSBundle mainBundle] loadNibNamed:@"SearchResultsTableViewCell" owner:self options:nil]];
What is wrong with this?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"SearchResultsTableViewCell";
SearchResultsTableViewCell *cell = (SearchResultsTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSArray alloc] initWithArray:[[NSBundle mainBundle]
loadNibNamed:@"SearchResultsTableViewCell"
owner:self options:nil]];
for (id currentObject in topLevelObjects) {
if ([currentObject isKindOfClass:[UITableViewCell class]]) {
cell = (SearchResultsTableViewCell *) currentObject;
break;
}
}
[topLevelObjects release], topLevelObjects = nil ;
}
Product *product = [productMutableArray objectAtIndex:indexPath.row];
cell.textLabel.text = product.title;
cell.detailTextLabel.text = product.desc1;
UIImageView *imageView = nil;
if (product.photo == nil) {
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ph38x38.jpg"]];
} else {
imageView = [[UIImageView alloc] initWithImage:product.photo];
}
imageView.frame = CGRectMake(10., 3., 38., 38.);
[cell addSubview:imageView];
[imageView release];
return cell;
}
I also have many other leaks, but the tools do not even show a line in the code, for example, there is a leak: GenerlaBlock-64 - UIKit - GetContextStack How can I solve this? Where should I look for him?
I was looking for some tutorials, but they all show only trivial examples with the preservation of count, alloc, release
source
share