Теперь у него нет свойства копирования в ARC, так что мне делать, когда я хочу скопировать объект? Затем я пишу тестовый код:
test.h
@property (strong, nonatomic) NSMutableString *str1;
@property (strong, nonatomic) NSMutableString *str2;
test.m
self.str1 = [[NSMutableString alloc] initWithString:@"Hello"];
self.str2 = [self.str1 copy];
[self.str2 appendString:@"World"];
NSLog(@"str1:%@,str2:%@",self.str1,self.str2);
При запуске происходит сбой:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to mutate immutable object with appendString:'
Итак, что мне делать?