1.将数组内的元素逆序 :
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",nil];
NSArray* reversedArray = [[array reverseObjectEnumerator] allObjects];
NSLog(@"reversedArray:%@", reversedArray);
输出reversedArray:( 3, 2, 1)
2.在可变数组中插入一个数组
NSArray *array1 = @[@"2", @"1"];
NSMutableArray *array2 = [NSMutableArray arrayWithObjects:@"6",@"7", nil];
/**
* @param 0 起始位置
* @param count 数组个数
*/
NSRange range = NSMakeRange(0, [array1 count]);
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:range];
[array2 insertObjects:array1 atIndexes:indexSet];
NSLog(@"%@", array2);
输出array2: (2,1,6,7)