---
title: "reserveCapacity(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/string/reservecapacity(_:)"
---

# reserveCapacity(_:)

Reserves enough space in the string’s underlying storage to store the specified number of ASCII characters.

## Declaration

```swift
mutating func reserveCapacity(_ n: Int)
```

## Parameters

- `n`: The minimum number of ASCII character’s worth of storage to allocate.

## Discussion

Discussion Because each character in a string can require more than a single ASCII character’s worth of storage, additional allocation may be necessary when adding characters to a string after a call to reserveCapacity(_:). note: O(n)

## See Also

### Appending Strings and Characters

- [append(_:)](swift/string/append(_:)-4xa8f.md)
- [append(_:)](swift/string/append(_:)-4xi3j.md)
- [append(contentsOf:)](swift/string/append(contentsof:)-oxek.md)
- [append(contentsOf:)](swift/string/append(contentsof:)-9vb4t.md)
- [append(contentsOf:)](swift/string/append(contentsof:)-7est5.md)
- [append(contentsOf:)](swift/string/append(contentsof:)-9foms.md)
- [+(_:_:)](swift/string/+(_:_:).md)
- [+=(_:_:)](swift/string/+=(_:_:).md)
- [+(_:_:)](swift/string/+(_:_:)-6h59y.md)
- [+(_:_:)](swift/string/+(_:_:)-n329.md)
- [+(_:_:)](swift/string/+(_:_:)-9fm57.md)
- [+=(_:_:)](swift/string/+=(_:_:)-676gx.md)
