Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3273982
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:59:21+00:00 2026-05-17T18:59:21+00:00

I have two UITableViewControllers with a fairly simple ui flow. One UITableViewController loads another

  • 0

I have two UITableViewControllers with a fairly simple ui flow. One UITableViewController loads another UITableViewController when you select an item in the first UITableViewController.


(UITableViewController) List of Stories -> Select a Story -> (UITableViewController) List of Sentences


In the second UITableViewController (MakeSentenceDetailViewController) I can’t release my NSFetchedResultsController without causing an error (shown with Zombies set to on):

-[NSFetchRequest release]: message sent to deallocated instance 0x5b370f0

The retain count of the NSFetchedResultsController stays at 1 but when I try to release it in dealloc I get a crash.

The code, especially in regards to the NSFetchedResultsController is the same in both tableviews, but in the MakeSentenceDetailViewController I can’t release this NSFetchedResults Controller with a crash – giving me a leak.

How can I safely release my NSFetchedResultsController? Why does it work fine in the parent (first) tableviewcontroller – but not in the second?

I can provide code for the first UITableViewController but in regards to NSFetchedResultsController it’s declared and used in much the same way.

MakeSentenceTableViewController.h:

@interface MakeSentenceTableViewController : UITableViewController {
NSManagedObjectContext  *managedObjectContext;  
NSFetchedResultsController *fetchedResultsController;
}
@property (nonatomic, retain)  Story *story;
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
@end

MakeSentenceTableViewController.m (relevant code with NSFetchedResultsController):

 - (void)viewDidLoad {
 [super viewDidLoad];
 if (managedObjectContext == nil) 
 { 
 managedObjectContext = [(MyAppAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
 NSLog(@"After managedObjectContext: %@",  managedObjectContext);
 }
   NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
  NSEntityDescription *entity = [NSEntityDescription entityForName:@"Sentence" inManagedObjectContext:managedObjectContext];
  [request setEntity:entity];
  //sorting stuff:
  NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"order" ascending: YES];
  NSArray *sortDescriptors = [[NSArray alloc] initWithObjects: sortDescriptor, nil];
  [request setSortDescriptors:sortDescriptors];
  //[request setFetchBatchSize:FETCH_BATCH_SIZE];
  [sortDescriptors release];
  [sortDescriptor release];
  fetchedResultsController = [[NSFetchedResultsController alloc] 
    initWithFetchRequest:request managedObjectContext:managedObjectContext 
    sectionNameKeyPath:nil cacheName:nil];
  [request release];
  NSError *error;
  [fetchedResultsController performFetch:&error];
  NSLog(@"FetchedResultsController: %@", fetchedResultsController);
  NSLog(@"fetchedResultsController RetainCount at viewDidLoad: %d", [fetchedResultsController retainCount]);
 }

 - (void)dealloc {

  //Gotta figure out why I can't release this:
  [fetchedResultsController release]; //Crash! Burn! 
  NSLog(@"fetchedResultsController RetainCount at dealloc: %d", [fetchedResultsController retainCount]);
  [managedObjectContext release];
  [super dealloc];
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:59:22+00:00Added an answer on May 17, 2026 at 6:59 pm
    NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
    // ...snip...
    [request release];
    

    You’re releasing an object that you’ve relinquished ownership of (with -autorelease). You don’t get an error at the point of the other release because the NSFetchedResultsController is also retaining the fetch request; thus the controller is the one actually causing the crash when it releases the last reference to the fetch request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two webapplication, one is a simple authenticationsite which can authenticate the logged
In my 'Sectioned' UITableView I have two sections, the first one for Attributes like
I have two identical tables and need to copy rows from table to another.
I have two classes, and want to include a static instance of one class
I have two threads, one needs to poll a bunch of separate static resources
I have two spreadsheets... when one gets modified in a certain way I want
I have a UINavigationController with two UITableViewControllers pushed onto its stack. Is there any
I'm creating an iPad app, and I have two classes: NWRootViewController : UITableViewController and
I have two NSMutableString objects defined in my viewController's (a subclass of UITableViewController) .h
i have two richtextboxes one below the other in my application.when the user start

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.