1.深.淺拷貝
2.copy.strong
NSMutableArray *books = [@[@"book1"] mutableCopy];
Person *person = [[Person alloc] init];
person.bookArray1 = books;
person.bookArray2 = books;
[books addObject:@"book2"];
NSLog(@"bookArray1:%@",person.bookArray1);
NSLog(@"bookArray2:%@",person.bookArray2);
使用strong修飾的person.bookArray1輸出是[book1,book2],
而使用copy修飾的person.bookArray2輸出是[book1]
其實就是不同的修飾符亮隙,對應(yīng)不同的setter方法韩脏,
strong對應(yīng)的setter方法慎陵,是將_property先release(_property release)陋葡,然后將參數(shù)retain(property retain)谭企,最后是_property = property祠墅。
copy對應(yīng)的setter方法,是將_property先release(_property release)响谓,然后拷貝參數(shù)內(nèi)容(property copy)损合,創(chuàng)建一塊新的內(nèi)存地址,最后_property = property娘纷。