【发布时间】:2013-10-10 04:49:31
【问题描述】:
我在 Core Data 中有一个很大的对象列表(大约 50 000 个并且定期增加)。我通过以下请求获取它:
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:[SongObject name]];
fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]];
fetchRequest.propertiesToFetch = @[@"uid", @"name", @"toArtistRef.uid", @"toArtistRef.name"];
fetchRequest.resultType = NSDictionaryResultType;
实体 SongObject 也包含关系toSongsInPlaylistRef,它是对多的。
我需要为每个对象获取此集合的计数。由于数据量大,我无法获取关系本身。
我尝试添加
@"toSongsInPlaylistRef.@count" 和 @"toSongsInPlaylistRef.count"
但它崩溃了
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Invalid to many relationship in setPropertiesToFetch: (toSongsInPlaylistRef.count)'
请写出任何建议。
【问题讨论】:
标签: ios objective-c core-data