• 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
Core Data derived property not recognized after save & reopen
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data derived property not recognized after save & reopen


  • Subject: Core Data derived property not recognized after save & reopen
  • From: David Catmull <email@hidden>
  • Date: Tue, 17 Nov 2009 21:02:41 -0800

I have an entity with a "date" property, and derived properties "year" and "month" (by having year/month methods in my NSManagedObject subclass). In a couple of different places, I fetch the entries from a particular year or month- the fetch requests's predicate says "year == 2009".

This works fine except in a document that has been saved and reopened: the first time I make a change to an object, and then try to fetch a list of objects by year, an exception is thrown saying "keypath year not found". What confuses me is that between reopening the document, and making a change, I can make (as far as I can tell) the same request to filter by year (or month) without problems. It doesn't matter which property I change - date or anything else.

So I have two questions:
1. Why would this happen?
2. What's a good, simple way to write a unit test that simulates closing an reopening a Core Data document? I want to avoid actual file operations for the sake of simplicity, but NSPersistentDocument does not implement the dataOfType:error: method.

--
David Catmull
email@hidden
http://www.uncommonplace.com/

_______________________________________________

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

  • Follow-Ups:
    • Re: Core Data derived property not recognized after save & reopen
      • From: "Sean McBride" <email@hidden>
    • Re: Core Data derived property not recognized after save & reopen
      • From: David Catmull <email@hidden>
  • Prev by Date: Re: API for Open Directory domain?
  • Next by Date: Re: How to stop NSScrollView from scrolling to top when horizontally resizing contained NSTextView?
  • Previous by thread: Re: API for Open Directory domain?
  • Next by thread: Re: Core Data derived property not recognized after save & reopen
  • Index(es):
    • Date
    • Thread