Instance Method

arrayByAddingObject:

Returns a new array that is a copy of the receiving array with a given object added to the end.

Declaration

- (NSArray<ObjectType> *)arrayByAddingObject:(ObjectType)anObject;

Parameters

anObject

An object.

Return Value

A new array that is a copy of the receiving array with anObject added to the end.

Discussion

If anObject is nil, an NSInvalidArgumentException is raised.

See Also

Deriving New Arrays

- arrayByAddingObjectsFromArray:

Returns a new array that is a copy of the receiving array with the objects contained in another array added to the end.

- filteredArrayUsingPredicate:

Evaluates a given predicate against each object in the receiving array and returns a new array containing the objects for which the predicate returns true.

- subarrayWithRange:

Returns a new array containing the receiving array’s elements that fall within the limits specified by a given range.