Instance Method

setObject:atIndexedSubscript:

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

Declaration

- (void)setObject:(ObjectType)obj atIndexedSubscript:(NSUInteger)idx;

Parameters

anObject

The object with which to replace the object at index index in the array. This value must not be nil.

index

The index of the object to be replaced. This value must not exceed the bounds of the array.

Discussion

This method has the same behavior as the replaceObjectAtIndex:withObject: method.

If index is beyond the end of the array (that is, if index is greater than or equal to the value returned by count), an NSRangeException is raised.

You shouldn’t need to call this method directly. Instead, this method is called when setting an object by index using subscripting.

mutableArray[3] = @"someValue"; // equivalent to [mutableArray replaceObjectAtIndex:3 withObject:@"someValue"]

See Also

Replacing Objects

- replaceObjectAtIndex:withObject:

Replaces the object at index with anObject.

- replaceObjectsAtIndexes:withObjects:

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

- 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.

- 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.