踩进了 CoreData To-Many Ordered 问题的老坑

这已经是个老bug了,如果对多关系标成有序的,有些 Dynamically-Generated accessor Methods (add*) 会抛异常,还有一些干脆没生成。

我居然又中招了!去年已经中过的,没记性呀!这绝逼是个bug,有人老早做过补丁:https://github.com/CFKevinRef/KCOrderedAccessorFix

不过,这意思苹果的人是铁了心不修了,radar 上那个条目已经关闭了。

好在文档里提过的 -mutableOrderedSetValueForKey: 方法一直工作都很正常。唉,苹果准备花几年来更新文档呢? (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOs.html#//apple_ref/doc/uid/TP40001803-SW3) :

Typically, however, you do not want to set an entire relationship,
instead you want to add or remove a single element at a time. To do
this, you should usemutableSetValueForKey: or one of the
automatically-generated relationship mutator methods (see
Dynamically-Generated Accessor Methods): unless it is order!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值