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 4333620
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:25:05+00:00 2026-05-21T10:25:05+00:00

I’m working on App with coreData and i get an error that i can’t

  • 0

I’m working on App with coreData and i get an error that i can’t understand: In a custom init whether i define NSFetchedResultController with “self.controller = new_controller” all works correctly, if i define only “controller = new_controller” (without self), error “The NSManagedObject has been invalidated” occur after 2 loops for the situation described in this image:
Error

Application parts interested in this error is here described:

  • A Table with a list of Months (Class MonthListVC, step 1 in the image). Where
    sections describe Month (like April
    2011) and the unique Row for any
    section present data (that are sum
    from transactions happened during the
    month).

  • Selecting one of these Row a next
    Table is pushed in navigation
    controller
    (Class WeekTVC, step 2 in the image), this table presents
    detail for every weeks for selected month. Here section title has format “week beginning – week end”, and the unique row for the section is a sum of transactions for the week.

  • A NSManagedObjectContext is passed via a custom init method (check the code)

  • every data for these tables are managed with
    NSFetchedResultController.

Here the code for selection on first Table (MonthListVC)

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

    id <NSFetchedResultsSectionInfo> sectionInfo = [[self.controller sections] objectAtIndex:indexPath.section];

    // get the first object for this section and get its date.
    NSDate *datepoint = [[[sectionInfo objects]objectAtIndex:0] date];

    //Create next Controller and push it into Navigation
    WeeksTVC *weeksTVC = (WeeksTVC*)[[WeeksTVC alloc] initWithContext:self.context datepoint:datepoint withTitle: [sectionInfo name] ];

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

    [weeksTVC release];
}

And here the code for WeeksTVC custom init method, where i define “self.controller = …” and where i get the problem whether i write only “controller = …”.
“controller” is a synthesized property.

-(WeeksTVC *)initWithContext:(NSManagedObjectContext *)n_context datepoint:(NSDate*)n_datePoint withTitle:(NSString*) stringTitle{   
    self = [self init];

    if(self !=nil){ 

        self.title =  [NSString stringWithFormat:@"History (%@)",stringTitle];

        //Back button setup
        UIBarButtonItem *barButton = [[UIBarButtonItem alloc] init];
        barButton.title = @"Back";
        self.navigationItem.backBarButtonItem = barButton; 

        //datePoint = n_datePoint;
        self.context = n_context;

        //Get Begin and End week information for this datePoint
        NSDate *startDay = [[CommonHelper weekInfoFromData:[CommonHelper firstDayOfMonthForDate:n_datePoint]] objectForKey:@"begin"];
        NSDate *endDay = [[CommonHelper weekInfoFromData:[CommonHelper lastDayOfMonthForDate:n_datePoint]] objectForKey:@"end"];

        //Manage Request
        NSFetchRequest *request = [[NSFetchRequest alloc]init];
        request.entity = [NSEntityDescription entityForName:@"Transactions" inManagedObjectContext:self.context];
        request.predicate = [NSPredicate predicateWithFormat:@"(date >= %@) && (date <= %@)",startDay,endDay]; 
        NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"date" ascending:NO];
        NSArray *sortDescs = [NSArray arrayWithObjects:sort,nil];
        request.sortDescriptors = sortDescs;

        "HERE THE PROBLEM WITH SELF***********************************************"
        //Manage NSResultFetchedController 
        self.controller = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:self.context sectionNameKeyPath:@"byWeek" cacheName:nil];
        self.controller.delegate = self;
        NSError *error = nil;

        //Fetch
        [self.controller performFetch:&error];
        "END OF PROBLEM***********************************************************"

        [request release];  
        [barButton release];
    }
    return self;
}

I report also dealloc method for WeeksTVC, i found that if i don’t release context and controller in this method… no error occur also if i write in init method “controller = ” and not “self.controller = “

- (void)dealloc {
    //[self.datePoint release];
    [self.controller release];
    [self.context release];
    [super dealloc];
}

Why self.controller and controller are so different in this case ???
In init method i ever write ivar without self -.-‘

  • 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-21T10:25:06+00:00Added an answer on May 21, 2026 at 10:25 am

    In custo init method for WeeksTVC i wrote

    self = [self init];
    

    and not

    self = [super init];
    

    This cause the problem… but i’m curious to understand what happen exactly…

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

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.