1 A * a1 = [A new]; 2 A * a2 = [A new]; 3 A * a3 = [A new]; 4 A * a4 = [A new]; 5 NSMutableArray *arr = [[NSMutableArray alloc]initWithArray:@[a1,a2,a3]]; 6 [MyArr replaceObjectAtIndex:0 withObject:a4];
结果 MyArr = @[a4,a2,a3];
1 A * a1 = [A new]; 2 A * a2 = [A new]; 3 A * a3 = [A new]; 4 A * a4 = [A new]; 5 NSMutableArray *arr = [[NSMutableArray alloc]initWithArray:@[a1,a2,a3]]; 6 [MyArr replaceObjectAtIndex:0 withObject:a4];
结果 MyArr = @[a4,a2,a3];