1

With Core Data Fetched Properties, how do I perform this simple request:

I want the Fetched Property (myFetchProp) to be on store StoreA, and it should do:

[myFetchProp getMeRecordWithPredicate:@“X == 35” inEntity:@“entityH” fromStore:StoreB];

Forgive my wrong-syntax, but I suppose my point is easy to understand.

I can’t find any simple and clear example on the net. I presume that should not be so difficult.

Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
Michel
  • 10,303
  • 17
  • 82
  • 179
  • 1
    possible duplicate of [does anyone have a working example of a fetched-property in core-data?](http://stackoverflow.com/questions/7341853/does-anyone-have-a-working-example-of-a-fetched-property-in-core-data) – Drux Mar 06 '15 at 08:35
  • Yes, I already saw this post before. That is not exactly what I call simple though. I wish there were a more basic use case. – Michel Mar 07 '15 at 07:08

1 Answers1

1

Since I have just read Marcus S. Zarra's Core Data: Data Storage and Management for iOS, OS X, and iCloud (2nd edition) (see here and here) let me quote it on the topic:

In practice, I have found fetched properties to be less useful and less flexible than either creating a stored fetch request or building the fetch request in code. Usually when a situation calls for a fetched property, it tends to be easier to subclass the entity in question, perform an NSFetchRequest in code, and return the results.

So the assumption that fetched properties can be simple may be wrong.

Community
  • 1
  • 1
Drux
  • 11,992
  • 13
  • 66
  • 116
  • This is giving me headaches. Even though I think I followed all the details I could find and I get no error or crash in my code, I always find zero items as the result of my FETCHED_PROPERTY, even when setting an empty predicate (though the entity has more than thirty items). I must be missing some obvious detail. – Michel Mar 08 '15 at 03:30
  • I finally got the thing working. In case someone else is in the same situation, this is the post that gave me the hint I needed to get out of trouble: http://stackoverflow.com/questions/3172495/fetched-properties-as-properties-of-an-nsmanagedobject-subclass – Michel Mar 08 '15 at 06:52