Ios CoreData(MagicalRecord)获取保存的对象
我有实体“墙柱”的结构,它有相同的结构实体“回购”。它们之间存在关系(“墙柱”具有“重新张贴”,目的地为“墙柱”,反向为“重新张贴”) 现在我用代码获取对象Ios CoreData(MagicalRecord)获取保存的对象,ios,database,core-data,magicalrecord,Ios,Database,Core Data,Magicalrecord,我有实体“墙柱”的结构,它有相同的结构实体“回购”。它们之间存在关系(“墙柱”具有“重新张贴”,目的地为“墙柱”,反向为“重新张贴”) 现在我用代码获取对象 NSArray *newsEntities = [[NSArray alloc] init]; newsEntities = [WallpostEntity findAllSortedBy:@"pubDate" ascending:NO]; 我有WallpostEntity和数组中的repost。我怎样才能只得到“墙柱
NSArray *newsEntities = [[NSArray alloc] init];
newsEntities = [WallpostEntity findAllSortedBy:@"pubDate" ascending:NO];
我有WallpostEntity和数组中的repost。我怎样才能只得到“墙柱” 我能想到的唯一一种方法是,您在这个获取请求中获得了两种不同类型的实体,即您已经将您的WallPost实体建模为Repost的基类。也就是说,Repost是Wallpost的一个子类。如果您只希望从您的请求返回Wallpost,那么您需要修改代码,如下所示:
NSFetchRequest *request = [WallpostEntity MR_requestAllSortedBy:@"pubDate" ascending:NO];
[request setIncludesSubEntities:NO];
newsEntities = [WallpostEntity MR_executeRequest:request];