---
title: "completions(forPartialWordRange:indexOfSelectedItem:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextview/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.

## Declaration

```swift
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

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

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:) if the delegate implements such a method.

## See Also

### Performing text completion

- [complete(_:)](appkit/nstextview/complete(_:).md)
- [insertCompletion(_:forPartialWordRange:movement:isFinal:)](appkit/nstextview/insertcompletion(_:forpartialwordrange:movement:isfinal:).md)
- [rangeForUserCompletion](appkit/nstextview/rangeforusercompletion.md)
