2014-04-15 109 views
0

我的结构具有实体'wall post',它具有相同的结构化实体'repost'。他们有关系('墙柱'与'目的地'重新发布''作为'墙柱',反转为'转贴')。CoreData(MagicalRecord)获取已保存的对象

与代码

 NSArray *newsEntities = [[NSArray alloc] init]; 
    newsEntities = [WallpostEntity findAllSortedBy:@"pubDate" ascending:NO]; 

现在我得到的对象我有WallpostEntity和转播的阵列。我怎样才能得到'墙上的帖子'?

回答

0

我可以想到,在这个获取请求中获得两种不同类型的实体的唯一方法是,您已将WallPost实体建模为Repost的基类。也就是说,Repost是Wallpost的一个子类。如果您只希望Wallposts从您的请求中返回,那么您需要像这样修改代码:

NSFetchRequest *request = [WallpostEntity MR_requestAllSortedBy:@"pubDate" ascending:NO]; 
[request setIncludesSubEntities:NO]; 
newsEntities = [WallpostEntity MR_executeRequest:request]; 
相关问题