@interface ViewController ()
@property (nonatomic,copy)NSMutableArray *array;//可变数组用copy修饰
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.array = [[NSMutableArray alloc]init];
for (int i = 0; i<5; i++) {
UIImage *img = [[UIImage alloc]init];
[self.array addObject:img];//报错[__NSArray0 addObject:]: unrecognized selector sent to instance 0x7fff8062d570
在这里可变数组使用copy来修饰了,然后在使用的时候addObject 报错[__NSArray0 addObject:]: unrecognized selector sent to instance 0x7fff8062d570
//本例问题解析:
//NSMutableArray 是NSArray的子类,NSMutableArray中有addObject方法,而父类中没有
//所有当使用copy来修饰的时候,数组变成了不可变的,再去调用可变数组的方法的时候就会报错方法找不到