I have an NSMutableArray with NSManagedObjects that I pulled back from the database. What I'm trying to do is filter out certain objects in the array based on individual object properties. By filter out I mean remove from the array. The problem is that when doing a shallow copy and removing an object from arrayTwo ends up removing the NSManagedObject from the original array that I copied from. I looked up a few different ways to apply a deep copy so that I can filter out object from my second array without impacting the first array. Here is the code I'm using to do this:
NSMutableArray *copyOfChestExercises = [[NSMutableArray alloc]initWithArray:_chestExercises copyItems:YES];
The problem is I get the following exception:
[Exercise copyWithZone:]: unrecognized selector sent to instance 0x15679f20'
when trying to do the copy. I've read a few posts stating that I need a copyWithZone implementation to do this and have in interface. I also read a few posts claiming that NSManagedObjects cannot be copied in the manner I'm trying to do. If anyone has tips or advice on how to do this or if it can't be done the way I'm doing it, it would be much appreciated.