1.Property of mutable type 'NSMutableArray' has 'copy' attribute; an immutable object will be stored instead;
**Exam** : @property (nonatomic, copy) NSMutableArray *coursesArray;
**Reason:**
defined:@property (copy, nonatomic) NSMutableArray *words;
NSArray *fixedWords = @[@"One",@"Two", @"Three", @"Four", @"Five", @"Six", @"Seven", @"Eight"];
NSMutableArray *mutableWords = [[NSMutableArray alloc] initWithArray:fixedWords];
self.words = mutableWords;
[self.words removeOjbectAtIndex:2];
這時候會出錯:unrecoginzed selector sent to instance;
copy 通常會返回不可變的副本。
因此,當一個NSMutableArray設置copy,會返回一個NSArray類型的包含同樣數據的結構。
此處建議用strong來修飾mutableArray.
說到這里 就得提一下copy 、 mutableCopy 以及strong的區別。關于copy 、mutableCopy 、strong三者間的關系