I want my app to know what the QuickType suggestions are. QuickType has gotten more context-aware recently, and you can type something like "auto r" and expect to see "repair" and "racing" as suggestions.
I've found UITextChecker, which can suggest completions for a single word but isn't context-aware. From http://nshipster.com/uitextchecker/ :
let textChecker = UITextChecker()
let partial = "auto r"
let completions = textChecker.completionsForPartialWordRange(
NSRange(0..<partial.utf16.count), inString: partial,
language: "en_US")
print(completions) # prints "[]"
I've tried getting a UILexicon from a UIInputViewController, but Apple's documentation says "Apple intends for you to consider the words in a lexicon object as supplementary to an autocorrection/suggestion lexicon of your own design" (link). So I guess this isn't the smart QuickType suggestions. It's not giving me any suggestions (tested in simulator):
let ivc = UIInputViewController()
ivc.textDocumentProxy.insertText("auto r")
ivc.requestSupplementaryLexiconWithCompletion { (lexicon:UILexicon) in
print("Called") // prints "Called"
print(lexicon.entries) // prints "[]", no suggestions
}
Does Apple not intend to expose the QuickType suggestions to us?