<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSString/getCharacters(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSString(im)getCharacters:"
  },
  "title" : "getCharacters(_:)"
}
-->

# getCharacters(_:)

Copies all characters from the receiver into a given buffer.

```
func getCharacters(_ buffer: UnsafeMutablePointer<unichar>)
```

## Parameters

`buffer`

Upon return, contains the characters from the receiver. `buffer` must be large enough to contain all characters in the string (`[string length]*sizeof(unichar)`).

## Discussion

Invokes [`getCharacters(_:range:)`](/documentation/Foundation/NSString/getCharacters(_:range:)) with `buffer` and the entire extent of the receiver as the range.

## See Also

[`length`](/documentation/Foundation/NSString/length)

The number of UTF-16 code units in the receiver.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)