There is an array:
NSArray* array1 = [[NSArray alloc] initWithObjects:@1, @2, @3, @4]; Create a new one:
NSMutableArray* array2 = [[NSMutableArray alloc] initWithCapacity:20]; And I want to fill it with 20 positions with elements from the first array of array1. Do I think that you can first [array2 addObjectsFromArray:array1]; and add the remaining elements via for ?
for(int i =0; i<4; i++) { [array2 addObject:[array1 objectAtIndex:0+i]]; } It works, but if I exceed the number of elements in the first array (i> 4), an error occurs.