nsmutablecopying

Using -mutableCopyWithZone: on custom class makes it immutable

£可爱£侵袭症+ 提交于 2020-01-05 06:54:27
问题 I've created a custom class which conforms to NSCopying and NSMutableCopying . I've added an implementation for -copyWithZone: and -mutableCopyWithZone: , but whenever I call -mutableCopy on my object and try to call another method, it crashes because some of the ivars have become immutable, even though I call -mutableCopyWithZone: on the ivars. Here's how I'm copying my class: MyObject *flipped = [list mutableCopy]; [MyObject flip:flipped]; (the code fails on +flip: , because it tries to use