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

  • SEARCH
  • Home
  • 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 3855776
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:49:41+00:00 2026-05-19T17:49:41+00:00

ich have the following problem: I’m using a the construct of the default Navigation

  • 0

ich have the following problem:

I’m using a the construct of the default “Navigation based Application | Use core data to storage”.

My RootViewController holds kind of categories. Selecting one, the navigation controller will push another (default) table-view controller (ItemsViewController). This is constructed as the RootViewController (managedObjectContext_ and fetchedResultsController_). There is just one change: The fetchedResultsController uses a predicate for fetching items of the selected category.

The error occurs when the navigation controller pops and the ItemsViewController releases the fetchedResultsController_ in dealloc.

- (void)dealloc {
    [fetchedResultsController_ release]; // is not nil and causes error
    [managedObjectContext_ release];
    self.category = nil;
    [super dealloc];
}

Stack:

0  0x010fca63 in objc_msgSend ()
1  0x010ffbe0 in __FUNCTION__.13263 ()
2  0x00d2ef73 in -[_PFBatchFaultingArray dealloc] ()
3  0x00daa236 in -[NSFetchedResultsController dealloc] ()
4  0x00004762 in -[ItemsViewController dealloc] (self=0x4d11e00, _cmd=0xfd09d6)
5  0x00385f1d in -[UINavigationController setDisappearingViewController:] ()
6  0x003834f6 in -[UINavigationController _clearLastOperation] ()
7  0x00383e3f in -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] ()
8  0x00510e23 in -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] ()
9  0x00511fd2 in -[UINavigationTransitionView _cleanupTransition] ()
10 0x002fd665 in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] ()
11 0x002fd4f7 in -[UIViewAnimationState animationDidStop:finished:] ()
12 0x01e816cb in run_animation_callbacks ()
13 0x01e81589 in CA::timer_callback ()
14 0x00f7bfe3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
15 0x00f7d594 in __CFRunLoopDoTimer ()
16 0x00ed9cc9 in __CFRunLoopRun ()
17 0x00ed9240 in CFRunLoopRunSpecific ()
18 0x00ed9161 in CFRunLoopRunInMode ()
19 0x018cf268 in GSEventRunModal ()
20 0x018cf32d in GSEventRun ()
21 0x002db42e in UIApplicationMain ()
22 0x00002330 in main (argc=1, argv=0xbffff094)

Category selection:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

ItemsViewController *ivc = [[ItemsViewController alloc] initWithStyle:UITableViewStylePlain];
ivc.managedObjectContext = self.managedObjectContext;
ivc.category = [self.fetchedResultsController objectAtIndexPath:indexPath];

[self.navigationController pushViewController:ivc animated:YES];

[ivc release];
}

Interface:

@interface ItemsViewController : UITableViewController <NSFetchedResultsControllerDelegate> {

    RankCategory *category;

@private
    NSFetchedResultsController *fetchedResultsController_;
    NSManagedObjectContext *managedObjectContext_;
}

@property (nonatomic, retain) RankCategory *category;

@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;

@end

Implementation:

@synthesize category;
@synthesize fetchedResultsController=fetchedResultsController_, managedObjectContext=managedObjectContext_;

- (NSFetchedResultsController *)fetchedResultsController {

if (fetchedResultsController_ != nil) {
    return fetchedResultsController_;
}

/*
 Set up the fetched results controller.
 */
// Create the fetch request for the entity.
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Item" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];

// Set the batch size to a suitable number.
[fetchRequest setFetchBatchSize:20];

// Edit the sort key as appropriate.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"itemName" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];

[fetchRequest setSortDescriptors:sortDescriptors];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"category = %@",self.category];
[fetchRequest setPredicate:predicate];

// Edit the section name key path and cache name if appropriate.
// nil for section name key path means "no sections".
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
aFetchedResultsController.delegate = self;
self.fetchedResultsController = aFetchedResultsController;

[aFetchedResultsController release];
[fetchRequest release];
[sortDescriptor release];
[sortDescriptors release];
[predicate release];

NSError *error = nil;
if (![fetchedResultsController_ performFetch:&error]) {
    /*
     Replace this implementation with code to handle the error appropriately.

     abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
     */
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    abort();
}

return fetchedResultsController_;
}    
  • 1 1 Answer
  • 1 View
  • 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-19T17:49:42+00:00Added an answer on May 19, 2026 at 5:49 pm

    Run the static analyzer on your code; build and analyze. I see at least one apparent retain/release problem.

    Specifically, predicate is created via +predicateWithFormat:, never retained, and is released near the end of the method, leading to an over-release likely out from under the fetch request and fetched results controller.

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

Sidebar

Related Questions

Hello ich have a Problem with my Pagination . The numbers() just show the
I have a JSON data object and a text/html javascript template written using the
I have following code, after five tries (wrong words like dfasfasfb) the application stops.
ich have a little Problem to write a .net code. I have an example
ich have a xml file with the following structure: <layer1 name=this is layer1> <messages>
I keep running into this problem over and over. I have a view with
I type the following url in my browser: http://localhost:8000/en/weblog/2010/aug/10/wie-baue-ich-ein-weblog/ an I get a Page
ich have thios foreach loop to create an array. After or before it is
Problem is to create a std::vector data table ( struct MegaTable , from the
I am using following code to convert an image to Icon. Here is my

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.