我刚刚开始将 NSOrderedSet
与 Core Data 一起使用,并且我尝试添加的第一个对象失败了。我发现这篇文章描述了失败:Exception thrown in NSOrderedSet generated accessors
现在我想删除特定索引处的对象。当我调用生成的 Core Data 方法时,我收到发送到实例的无法识别的选择器。对我来说,它看起来像:
removeObjectFromAddressAnnotationsAtIndex:
我想知道我是否做错了什么,或者这个生成的方法是否也存在错误。当我进入时,我看到我的索引确实与我的预期一致,所以我不确定它是什么。
编辑:
我这样使用它:
[_route removeAddressAnnotationsAtIndexes:[NSIndexSet indexSetWithIndex:indexToRemove]];
[_route removeObjectFromAddressAnnotationsAtIndex:indexToRemove];
我已经尝试了这两种方法,但都失败并出现此错误:
[Route removeAddressAnnotationsAtIndexes:]: unrecognized selector sent to instance 0xea71980
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Route removeAddressAnnotationsAtIndexes:]: unrecognized selector sent to instance 0xea71980'
最佳答案
我几乎放弃了 NSOrderedSet
。它们有点笨拙,既不是从 NSArray
派生的,也不是从 NSSet
派生的,因此许多常用功能根本不可用。
在我的核心数据模型中,我添加了一个 position
或 order
属性来跟踪订单。简单可靠。
关于ios - removeObjectFromSetAtIndex,无法识别的选择器发送到实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19085923/