Re: Core Data derived property not recognized after save & reopen
Re: Core Data derived property not recognized after save & reopen
- Subject: Re: Core Data derived property not recognized after save & reopen
- From: "Sean McBride" <email@hidden>
- Date: Wed, 18 Nov 2009 17:13:07 -0500
- Organization: Rogue Research Inc.
On 11/17/09 9:02 PM, David Catmull said:
>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.
What do you mean exactly by "derived properties"? Are they transient?
Are they in your xcdatamodel? In any case, I believe your problem is
that you can only fetch against properties that are in the persistent
store ie in your xcdatamodel and not transient.
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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