美文网首页iOS寒哥管理的技术专题
Core Data中NSOrderedSet添加成员会崩溃

Core Data中NSOrderedSet添加成员会崩溃

作者: 原子墨 | 来源:发表于2015-03-13 10:53 被阅读0次

最近把项目里CoreDataModel的一个一对多的关系改为有序的,对象的class因此从NSSet变为NSOrderedSet。

@property (nonatomic, retain) NSOrderedSet *myFlowDetail;

- (void)addMyFlowDetailObject:(MyFlowDetailEntity *)value;

使用中却发现向NSOrderedSet里添加对象时回崩溃,经查询发现似乎是Apple从2011年到现在都没解决的bug。
临时解决方法是给这个类添加一个category覆盖上述方法:

- (void)addMyFlowDetailObject:(MyFlowDetailEntity *)value
{
    NSMutableOrderedSet *flowDetail = [[NSMutableOrderedSet alloc] initWithOrderedSet:self.myFlowDetail];
    [flowDetail addObject:value];
    self.myFlowDetail = flowDetail;
}

参考:Exception thrown in NSOrderedSet generated accessors

相关文章

网友评论

    本文标题:Core Data中NSOrderedSet添加成员会崩溃

    本文链接:https://www.haomeiwen.com/subject/faybxttx.html