Can I set transient properties to fetch?

2019-04-26 21:12发布

问题:

I want to create NSFetchRequest and set properties to fetch like this:

request.propertiesToFetch = @[@"a", @"b", @"c"];

where a and b are stored in Core Data database, and c is transient. executeFetchRequest: fires an error Invalid keypath c passed to setPropertiesToFetch:. But if I uncheck transient-checkbox for property c everything will work fine. So is it really impossible to fetch transient properties or I'm doing something wrong?

回答1:

Yes, it is really impossible. You can't fetch them because they don't exist in the persistent store - that's what it means to be transient. You can fetch whatever persistent attributes the derived, transient, attribute is created from.