gpt4 book ai didi

iphone - 预取是否应该返回任何错误?

转载 作者:行者123 更新时间:2023-11-29 13:33:45 25 4
gpt4 key购买 nike

我想看看我是否对使用 Core Data 进行预取有正确的理解。我正在为 Message 对象执行 batchSize 为 20 的获取请求,该对象与 MBDate 属性具有一对一的关系。我预取此属性:

[fetchRequest setRelationshipKeyPathsForPrefetching:
[NSArray arrayWithObjects:@"date", nil]];

预取命令完成,如此输出所示:

CoreData: annotation: Prefetching with key 'date'.  Got 9 rows.
CoreData: annotation: total fetch execution time: 0.0094s for 20 rows

但是,在第一批中,如果我这样做了

if(message.date.isFault) NSLog(@"isFault");,

它总是输出 isFault,即使我预取了它!如果我尝试访问 MBDate 对象的任何属性,则会触发错误请求:

CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZDATE, t0.ZDATESTRING FROM ZMBDATE t0 WHERE  t0.Z_PK = ? 
CoreData: annotation: sql connection fetch time: 0.0008s
CoreData: annotation: total fetch execution time: 0.0014s for 1 rows.
CoreData: annotation: fault fulfilled from database for : 0x85d22b0 <x-coredata://736D04C4-7DB3-40B7-B208-79B5DFD68260/MBDate/p61>

为什么预取没有通过?为什么我的对象仍然是错误的?我知道很难给出任何明确的答案,但任何提示或想法都会很棒!

最佳答案

你能在不设置批量大小的情况下尝试同样的事情吗?

fetchBatchSize 下的 NSFetchRequest 类引用中有一个奇怪的注释:

If you set a non-zero batch size, the collection of objects returned when the fetch is executed is broken into batches. When the fetch is executed, the entire request is evaluated and the identities of all matching objects recorded, but no more than batchSize objects’ data will be fetched from the persistent store at a time. The array returned from executing the request will be a proxy object that transparently faults batches on demand.

就好像你设置了 batchSize 无论如何返回的对象都会出错。

关于iphone - 预取是否应该返回任何错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11178424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com