Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios CoreData(MagicalRecord)获取保存的对象_Ios_Database_Core Data_Magicalrecord - Fatal编程技术网

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];