Prepares the collection to store the specified number of elements, when doing so is appropriate for the underlying type.
- iOS 7.0+
- macOS 10.9+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
- Xcode 8.0+
The requested number of elements to store.
If you will be adding a known number of elements to a collection, use this method to avoid multiple reallocations. A type that conforms to
Range can choose how to respond when this method is called. Depending on the type, it may make sense to allocate more or less storage than requested or to take no action at all.