When running my iPhone app code with memory leak tool it says that i have two memory leaks in this method. The first when calling cell.textLabel setText: and the second when calling cell.imageView setImage:
I can't figure out what it's wrong, please can you help me?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"IssuesCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
// The issue object
Issue *issue;
issue = [issues objectAtIndexPath:indexPath];
// Issue name
[cell.textLabel setText:[issue name]];
// Get a string from the issue date
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
[cell.detailTextLabel setText:[dateFormatter stringFromDate:[issue date]]];
[dateFormatter release];
[cell.imageView setImage:[UIImage imageNamed:[issue cover]]];
return cell;
}
Issue definition:
#import <CoreData/CoreData.h>
@class Article;
@interface Issue : NSManagedObject
{
}
@property (nonatomic, retain) NSString * cover;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSDate * date;
@property (nonatomic, retain) NSSet* articles;
@end
@interface Issue (CoreDataGeneratedAccessors)
- (void)addArticlesObject:(Article *)value;
- (void)removeArticlesObject:(Article *)value;
- (void)addArticles:(NSSet *)value;
- (void)removeArticles:(NSSet *)value;
@end
And implementation
#import "Issue.h"
#import "Article.h"
@implementation Issue
@dynamic cover;
@dynamic name;
@dynamic date;
@dynamic articles;
@end