• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
re: More CoreData questions...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: More CoreData questions...


  • Subject: re: More CoreData questions...
  • From: Ben Trumbull <email@hidden>
  • Date: Tue, 15 Jan 2008 18:20:59 -0800

Mike,

When I get to the first table that I need to recreate a one-to many relationship I find that if after specifying the first connection if I don't force a save of the managedObjectContext then the next fetch that is for the index comes up with 0 results. Here is part of my
code...

It's a little hard to tell from the code excerpt that omits the definition of the fetch request, the relationships involved, etc. but my guess is that you're encountering a limitation of the in memory filtering that is applied to uncommitted changes.


The -initWithEntity:insertIntoManagedObjectContext: method creates a new instance that is added to the list of pending insertions. Those are committed during the next save.

Executed a fetch request always goes to disk (searches the database) but the newly inserted objects haven't actually been saved yet. So the database returns 0 results. The NSManagedObjectContext notices it has a bunch of unsaved changes, and tries to adjust the results from the database query to accommodate the changes that have not yet been committed.

This adjustment is done by applying the same predicate from the fetch request to each dirtied (unsaved) managed object of the entity you're fetching. If the predicate matches the unsaved changes then inserted objects are added to the result set, deleted objects removed, etc.

Since the filtering is only done to managed objects of the entity you're fetching, it's possible to fail to notice that changes to related objects would have affected the predicate.

I infer from the excerpt that you're fetching Teachers. The teacher objects ought to be marked dirty by:
[t1 addClasses_TaughtObject:c];


so examining your fetch request and your custom setter code would be helpful.
--

-Ben
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Wrapping NSTask, setting PATH env var to current user's PATH...
  • Next by Date: Re: How to get pixel information from CIImage of QT frame
  • Previous by thread: More CoreData questions...
  • Next by thread: Fwd: More CoreData questions...
  • Index(es):
    • Date
    • Thread