Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory leaks in UITableView with NSMutableArray - How to stop them?
    primarykey
    data
    text
    <p>I'm pretty new to objective-c development and I'm to the point I'm beginning to test my application for leaks and patching up anything else I may have done wrong originally. I followed the examples from a book I bought and expanded on those ideas. The Leaks instrument is telling me in my tableView cellForRowAtIndexPath method I have a leak and I'm not sure on how to fix it. </p> <p>Here is the related .h contents:</p> <pre><code>@interface NewsListViewController : UITableViewController&lt;UIActionSheetDelegate&gt; { NSMutableArray *newsList, *account, *playerList;} </code></pre> <p>And here is the related .m contents:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)ip { static NSString *CellIdentifier = @"NewsCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; [cell autorelease]; } NSManagedObject *uNews = [newsList objectAtIndex:[ip row]]; NSManagedObjectContext *playerDBContext = [[AppController sharedAppController] managedObjectContext]; NSFetchRequest *playerDBRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *playerDBEntity = [NSEntityDescription entityForName:@"Players" inManagedObjectContext:playerDBContext]; [playerDBRequest setEntity:playerDBEntity]; NSPredicate *playerDBPredicate = [NSPredicate predicateWithFormat:@"playerID=%@", [uNews valueForKey:@"playerID"]]; [playerDBRequest setPredicate:playerDBPredicate]; NSError *playerDBError; NSArray *playerDBList = [playerDBContext executeFetchRequest:playerDBRequest error:&amp;playerDBError]; [playerDBRequest release]; playerList = [playerDBList mutableCopy]; NSString *playerInformation; if (![playerDBList count] == 0) { NSManagedObject *playerInfo = [playerList objectAtIndex:0]; playerInformation = [NSString stringWithFormat:@"%@, %@ (%@-%@)", [playerInfo valueForKey:@"playerLastName"], [playerInfo valueForKey:@"playerFirstName"], [playerInfo valueForKey:@"team"], [playerInfo valueForKey:@"position"]]; } else { //NSInteger playerID = (NSInteger *)[uNews valueForKey:@"playerID"]; [self addPlayer:(NSInteger *)[uNews valueForKey:@"playerID"]]; NSLog(@"%@", [uNews valueForKey:@"playerID"]); playerInformation = [uNews valueForKey:@"playerInfo"]; } cell.textLabel.text = playerInformation; cell.detailTextLabel.text = [uNews valueForKey:@"news"]; cell.selectionStyle = UITableViewCellSelectionStyleGray; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell;} </code></pre> <p>It's throwing the error on the playerList = [playerDBList mutableCopy]; line - Help with how to fix and an explanation would be greatly appreciated. It's probably from reallocating without releasing but when I've tried using [playerList release]; at the end of the cellForRowAtIndexPath my app crashes.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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