Core Data Fetched属性 - 基本(Core Data Fetched Properties - Basics)

IPhone IT屋
问 题

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.

解决方案

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.

本文地址:IT屋 » Core Data Fetched Properties - Basics

问 题

通过Core Data Fetched属性,我如何执行这个简单的请求:



我想要Fetched属性( myFetchProp )存储到 StoreA ,它应该:



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


原谅我的错误语法,但我想我的观点很容易理解。



我在网上找不到任何简单明了的例子。


解决方案

因为我刚刚读过Marcus S. Zarra的 核心数据:适用于iOS,OS X和iCloud的数据存储和管理 (第2版) (请参阅此处这里)让我引用它在主题:




在实践中,我发现抓取的属性不太有用,
比创建存储的抓取请求或者在代码中构建
获取请求。通常当情况需要一个
fetched属性时,它往往更容易子类化实体在
问题,在代码中执行 NSFetchRequest 返回结果。




因此,获取的属性可能很简单的假设可能是错误的。


本文地址:IT屋 » Core Data Fetched属性 - 基本