<!--
{
  "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/character(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSString(im)characterAtIndex:"
  },
  "title" : "character(at:)"
}
-->

# character(at:)

Returns the character at a given UTF-16 code unit index.

```
func character(at index: Int) -> unichar
```

## Parameters

`index`

The index of the character to retrieve.
  
  > Important:
  > Raises an `NSRangeException` if `index` lies beyond the end of the receiver.

## Return Value

The character at the array position given by `index`.

## Discussion

You should always use the [`rangeOfComposedCharacterSequence(at:)`](/documentation/Foundation/NSString/rangeOfComposedCharacterSequence(at:)) or [`rangeOfComposedCharacterSequences(for:)`](/documentation/Foundation/NSString/rangeOfComposedCharacterSequences(for:)) method to determine character boundaries, so that any surrogate pairs or character clusters are handled correctly.

---

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)