Core Data derived property not recognized after save & reopen
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