Initializer

init(capacity:)

Returns an array, initialized with enough memory to initially hold a given number of objects.

Declaration

init(capacity numItems: Int)

Parameters

numItems

The initial capacity of the new array.

Return Value

An array initialized with enough memory to hold numItems objects. The returned object might be different than the original receiver.

Discussion

Mutable arrays expand as needed; numItems simply establishes the object’s initial capacity.

This method is a designated initializer.

See Also

Creating and Initializing a Mutable Array

init()

Initializes a newly allocated array.