<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextView/completions(forPartialWordRange:indexOfSelectedItem:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextView(im)completionsForPartialWordRange:indexOfSelectedItem:"
  },
  "title" : "completions(forPartialWordRange:indexOfSelectedItem:)"
}
-->

# completions(forPartialWordRange:indexOfSelectedItem:)

Returns an array of potential completions, in the order to be presented, representing possible word completions available from a partial word.

```
func completions(forPartialWordRange charRange: NSRange, indexOfSelectedItem index: UnsafeMutablePointer<Int>) -> [String]?
```

## Parameters

`charRange`

The range of characters of the matched partial word to be completed.

`index`

On return, optionally set to the completion that should be initially selected. The default is 0, and –1 indicates no selection.

## Return Value

An array of potential completions, in the order to be presented, representing possible word completions available from a partial word at `charRange`. Returning `nil` or a zero-length array suppresses completion.

## Discussion

May be overridden by subclasses to modify or override the list of possible completions.

This method should call the delegate method [`textView(_:completions:forPartialWordRange:indexOfSelectedItem:)`](/documentation/AppKit/NSTextViewDelegate/textView(_:completions:forPartialWordRange:indexOfSelectedItem:)) if the delegate implements such a method.

---

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)