需要通过以下方式制作 NSMutableDictionary 的副本:
NSMutableDictionary *newScoutingEventDictionary = [[[NSMutableDictionary alloc] initWithDictionary:self.scoutingEvent copyItems:YES] mutableCopy];
但是当我尝试在其中改变一个数组时:
[[newScoutingEventDictionary objectForKey:@"myArray"] replaceObjectAtIndex:i withObject:appendedEntry];
它给了我一个错误:
-[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0x964d650
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0x964d650'
如果我尝试改变原始的 NSMutableDictionary:
[[self.scoutingEvent objectForKey:@"myArray"] replaceObjectAtIndex:i withObject:appendedEntry];
它运行得很好。为什么我的复制版本会破坏它?