0
votes

I just started using an NSOrderedSet with Core Data, and the first object I try to add, it fails. I found this post describing the failure: Exception thrown in NSOrderedSet generated accessors

Now I want to remove an object at a specific index. I get unrecognized selector sent to instance when I call the generated Core Data method. For me it looks like:

removeObjectFromAddressAnnotationsAtIndex:

I was wondering if I'm doing something wrong, or if there is also a bug for this generated method as well. When I stepped through, I saw my index did line up with what I expected so I'm not sure what it is.

Edit:

I use it like so:

[_route removeAddressAnnotationsAtIndexes:[NSIndexSet indexSetWithIndex:indexToRemove]];
[_route removeObjectFromAddressAnnotationsAtIndex:indexToRemove];

I've tried both, and both fail with this error:

[Route removeAddressAnnotationsAtIndexes:]: unrecognized selector sent to instance 0xea71980
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Route removeAddressAnnotationsAtIndexes:]: unrecognized selector sent to instance 0xea71980'
1
can you show the code you are using and the exact error? - Gabriele Petronella
@GabrielePetronella I added the code you requested. - Crystal
It doesn't look like the known bug in generated accessors, since Route doesn't appear to be responding to that selector. Are you sure that the method naming is correct and that the relationship is to-many in the core data model editor? - Gabriele Petronella
@GabrielePetronella Ya I just checked, it says M (to-many) for my Route entity. I also copied and pasted the method when I tried using it. I also am able to jump to the definition on those methods and I end up going to my Route.h file. But knowing that there is no known bug for this, then I'll just keep digging. Thanks! - Crystal
Try to override that method with your own implementation, place a breakpoint in it an see whether it gets called. - Gabriele Petronella

1 Answers

1
votes

I have pretty much given up on NSOrderedSet. They are a bit unwieldy being neither derived from NSArray nor from NSSet, so a lot of the usual functionality is simply not available.

In my Core Data models, I have included a position or order attribute to keep track of the order. Simple and reliable.