I am trying to copy one array to another:
NSMutableArray *itemsCopy = [[NSMutableArray alloc] initWithArray:self.items copyItems:YES];
but I ge
You need to make sure all the contents of self.items
adopt the NSCopying protocol.
If you just want a shallow copy, send the -mutableCopy
message to self.items
.
NSMutableArray *itemsCopy = [self.items mutableCopy];
You have to provide your classes with the copyWithZone
selector (according to NSCopying
protocol) if you are not copying objects that implement that protocol by default.
So if you are copying custom objects you have to implement it. The copy
method always calls copyWithZone
.. and you must always provide the implementation, it can't know what to copy inside objects by itself..