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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:01:09+00:00 2026-05-26T08:01:09+00:00

Good evening everyone, before explaining my problem, I should give you some explanation on

  • 0

Good evening everyone,

before explaining my problem, I should give you some explanation on my project first :

I have a simple Coredata model with one entity called “Conversation” and the other one “Message”. Basically, I need to kind of reproduce the iPhone sms application.

Conversation{  
    messages<-->>Message.conversation  
}  

Message{  
    conversation<<-->Conversation.messages  
}    

As you can see, my model is easy to understand. I asked some help a few weeks ago about how to implement these views altogether (i.e. using NSFetchedResultsController (FRC) or not in the view displaying messages from a specific conversation on this post.

So Wh at i did is that I use one FRC in each view. Another thread is from time to time updating my model. In order to notify my views that my model changed, I used this in my second thread :

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];  
[nc addObserver:self
       selector:@selector(mergeChanges:)
           name:NSManagedObjectContextDidSaveNotification
         object:_context];  

And the mergeChanges: function is doing this :

- (void)mergeChanges:(NSNotification *)notification {  
AppDelegate *appDel = (AppDelegate*)[[UIApplication sharedApplication] delegate];
NSManagedObjectContext *mainContext = [appDel managedObjectContext];

// Merge changes into the main context on the main thread
[mainContext performSelectorOnMainThread:@selector(mergeChangesFromContextDidSaveNotification:)
                              withObject:notification
                           waitUntilDone:YES];  
}  

This code was I thought working great because in both viewController (lets call them ConversationVC (where every conversations are listed) and MessageVC (where every messages from a specific conversations are listed)), I used :

- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller;
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath;
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller;  

My Problem however is the following :
When I’m inserting new messages in my second thread and the context is saved, the notification is sent to both views, even if the MessageVC is not being displayed. It’s not a property of my ConversationVC so when it gets poped, its value should be nil. (I think).

My question is : why is this sent to a view not being displayed ? I can’t see it’s value in the debugger anywhere. I tried to make it a property of the view and then assigned “nil” to it when coming back to the ConversationVC, but then I get a SIGBRT error saying that the notification was sent to a deallocated variable (which was logical).
I really need it to be sent only to the view currently displayed.
Do you have any idea ?

Thank you very much

  • 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-26T08:01:10+00:00Added an answer on May 26, 2026 at 8:01 am

    This might help some people :

    For that issue, I didn’t forget to call [NSNotificationCenter removeObserver:] because the method I was talking about where :

    - (void)controllerWillChangeContent:(NSFetchedResultsController *)controller;
    - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath;
    - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller;  
    

    These methods belongs to the NSFetchedResultsControllerDelegate. Basically, whenever a change is made to CoreData, and that your NSFetchedResultsController binds on the changed data, the delegate is called somehow, and calls these three methods.

    What I did was :

    - (void) viewDidDisappear {
        self.fetchedResultsController = nil; // using the property !
    }
    

    like that, if it gets called, the message will be sent to nil, which is authorized, and not to a deallocated instance variable.

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

Sidebar

Related Questions

Good evening everyone! I am working on learning some java and I have made
Good evening. For a project, I have to create a system. In this system,
Good evening everyone. I am currently using MVC 3 and I have a viewmodel
Good Evening, The problem is that i have both xcode 3.2 and xcode 4
Good evening, people! I'm trying to solve a rather simple problem, but.. well, it
Good evening everyone. I am puzzling over the oddity that the jQuery Marquee plugin
Good evening I've got a little problem with my DataGridView in a .NET Windows
Good evening, In my app that I'm currently developing, I have a class that
Good evening, I am working on a program where some application config info is
Good evening, i need to know how can i have one .h file that

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.