Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory leak when setting cell data in UITableView
    text
    copied!<p>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:</p> <p>I can't figure out what it's wrong, please can you help me?</p> <pre><code>- (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; } </code></pre> <p>Issue definition:</p> <pre><code>#import &lt;CoreData/CoreData.h&gt; @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 </code></pre> <p>And implementation</p> <pre><code>#import "Issue.h" #import "Article.h" @implementation Issue @dynamic cover; @dynamic name; @dynamic date; @dynamic articles; @end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload