开发者

What exactly is a fetched property?

What's the point of a 开发者_StackOverflowfetched property? Does someone have a good example what this is good for?


Some of the uses for fetched properties:

  1. Ordered relationships. The Core Data to-many relationship models a (unordered) set. You can provide the appearance of an ordered relationship using a fetched property with a sort descriptor (assuming there's a natural ordering to the elements).
  2. Cross-store relationships. Relationships in Core Data cannot span persistent stores. You can simulate such relationships using fetched properties, for example storing the objectIDs of the destination in a transformable property and fetching the elements of that collection of objectIDs. Obviously true cross-store relationships are problematic because there's no way to guarantee the presence of an other store at access time.
  3. Filtered relationships. Although fetched properties are not "live' (like iTunes' smart playlists), they can be used to easily filter members of one or more relationships according to attributes (persistent or transient) of any object in the connected object graph.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜