Instance Method

replaceObjectsInRange:withObjectsFromArray:range:

Replaces the objects in the receiving array specified by one given range with the objects in another array specified by another range.

Declaration

- (void)replaceObjectsInRange:(NSRange)range withObjectsFromArray:(NSArray<ObjectType> *)otherArray range:(NSRange)otherRange;

Parameters

aRange

The range of objects to be replaced in (or removed from) the receiving array.

otherArray

The array of objects from which to select replacements for the objects in aRange.

otherRange

The range of objects be selected from otherArray as replacements for the objects in aRange.

Discussion

The lengths of aRange and otherRange don’t have to be equal: If aRange is longer than otherRange, the extra objects in the receiving array are removed; if otherRange is longer than aRange, the extra objects from otherArray are inserted into the receiving array.

See Also

Replacing Objects

- replaceObjectAtIndex:withObject:

Replaces the object at index with anObject.

- setObject:atIndexedSubscript:

Replaces the object at the index with the new object, possibly adding the object.

- replaceObjectsAtIndexes:withObjects:

Replaces the objects in the receiving array at locations specified with the objects from a given array.

- replaceObjectsInRange:withObjectsFromArray:

Replaces the objects in the receiving array specified by a given range with all of the objects from a given array.

- setArray:

Sets the receiving array’s elements to those in another given array.