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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:48:10+00:00 2026-05-14T06:48:10+00:00

My app will allow users to create a personalised list of events from a

  • 0

My app will allow users to create a personalised list of events from a large list of events. I have a table view which simply displays these events, tapping on one of them takes the user to the event details view, which has a button “add to my events”.

In this detailed view I own the original event object, retrieved via an NSFetchedResultsController and passed to the detailed view (via a table cell, the same as the core data recipes sample). I have no trouble retrieving/displaying information from this “event”. I am then trying to add it to the list of MyEvents represented by a one to many (inverse) relationship:

alt text http://www.imgplace.com/img580/8008/44relationship.png

This code:

NSManagedObjectContext *context = [event managedObjectContext];
MyEvents *myEvents = (MyEvents *)[NSEntityDescription insertNewObjectForEntityForName:@"MyEvents" inManagedObjectContext:context];
[myEvents addEventObject:event];//ERROR

And this code (suggested below):

//would this add to or overwrite the "list" i am attempting to maintain
NSManagedObjectContext *context = [event managedObjectContext];
MyEvents *myEvents = (MyEvents *)[NSEntityDescription insertNewObjectForEntityForName:@"MyEvents" inManagedObjectContext:context];
NSMutableSet *myEvent = [myEvents mutableSetValueForKey:@"event"];
[myEvent addObject:event]; //ERROR

Bot produce (at the line indicated by //ERROR):

*** -[NSComparisonPredicate evaluateWithObject:]: message sent to deallocated instance

Seems I may have missed something fundamental. I cant glean any more information through the use of debugging tools, with my knowledge of them.

1) Is this a valid way to compile and store an editable list like this?

2) Is there a better way?

3) What could possibly be the deallocated instance in error?

—

I have now modified the Event entity to have a to-many relationship called “myEvents” which referrers to itself. I can add Events to this fine, and logging the object shows the correct memory addresses appearing for the relationship after a [event addMyEventObject:event];. The same failure happens right after this however. I am still at a loss to understand what is going wrong. This is the backtrace

#0  0x01f753a7 in ___forwarding___ ()
#1  0x01f516c2 in __forwarding_prep_0___ ()
#2  0x01c5aa8f in -[NSFetchedResultsController(PrivateMethods) _preprocessUpdatedObjects:insertsInfo:deletesInfo:updatesInfo:sectionsWithDeletes:newSectionNames:treatAsRefreshes:] ()
#3  0x01c5d63b in -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] ()
#4  0x0002e63a in _nsnote_callback ()
#5  0x01f40005 in _CFXNotificationPostNotification ()
#6  0x0002bef0 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#7  0x01bbe17d in -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] ()
#8  0x01c1d763 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] ()
#9  0x01ba25ea in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] ()
#10 0x01bdfb3a in -[NSManagedObjectContext processPendingChanges] ()
#11 0x01bd0957 in _performRunLoopAction ()
#12 0x01f4d252 in __CFRunLoopDoObservers ()
#13 0x01f4c65f in CFRunLoopRunSpecific ()
#14 0x01f4bc48 in CFRunLoopRunInMode ()
#15 0x0273878d in GSEventRunModal ()
#16 0x02738852 in GSEventRun ()
#17 0x002ba003 in UIApplicationMain ()

solution

I managed to get to the bottom of this.

I was fetching the event in question using a NSFetchedResultsController with a NSPredicate which I was releasing after I had the results. Retrieving values from the entities returned was no problem, but when I tried to update any of them it gave the error above. It should not have been released.

oustanding part of my question

What is a good way to create this sub list from a list of existing items in terms of a core data model. I don’t believe its any of the ways I tried here. I need to show/edit it in another table view. Perhaps there is a better way than a boolean property on each event entity? The relationship idea above doesn’t seem to work here (even though I can now create it).

Cheers.

  • 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-14T06:48:10+00:00Added an answer on May 14, 2026 at 6:48 am

    Assuming that you have named the MyEvents <--->> Event relationship as events

    MyEvents *myEvents = (MyEvents *)[NSEntityDescription insertNewObjectForEntityForName:@"MyEvents" inManagedObjectContext:context];
    
    NSLog(@"MYEVENTS: %@", myEvents);
    NSLog(@"EVENT: %@", event);
    
    // NSMutableSet to hold the events
    NSMutableSet *events = [event mutableSetValueForKey:@"events"];
    
    // Add the event to the set. Core Data takes care of the rest
    [events addObject:event];
    

    As per my comment, consider why you are creating a new Entity to manage a collection. NSFetchedResultsController and the NSFetchedResultsControllerDelegate protocol were designed to work closely with tableViews. Refer to Apple documentation on how to use these classes.

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

Sidebar

Related Questions

I am doing small Silverlight app which will allow users to Create orders. I
I am trying to create a small web app that will allow users to
I'm building an iPhone app, which will allow users to log in to a
I have a simple app that will allow a user to tag a location.
I have a very simple webforms app that will allow field techs to order
I'm trying to create a C# form app that will allow me to use
I have been task with (ha) creating an application that will allow the users
So I'm making a Rails app which allows Users to create Items, and each
I currently develop an iOS app which allow users to consult their account (account
Hello All I am writing some software that will allow users to create their

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.