1

我不明白 setFetchBatchSize 的含义。

在下面的代码中,我将获取批量大小设置为 20,但我的结果数组中仍然有 49 个对象(它们是查询中的所有对象)

        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"company.id = %@", company.id];
        NSFetchRequest *req = [CategoryEntity requestAllSortedBy:@"id" ascending:YES withPredicate:predicate];
        [req setFetchBatchSize:20];
        NSArray *results = [CategoryEntity executeFetchRequest:req];

那么setFetchBatchSize是什么意思,因为它似乎没有限制请求?

4

1 回答 1

4

要限制大小,请使用 fetchLimit。

对于批量大小,对象会出现故障。他们看起来像他们在那里,但那些只是存根。当您访问它们时 - 在幕后 - 然后填充这些值。

于 2011-03-09T11:48:53.330 回答