I have a controller that is taking custom key input and displaying it in a unique way. It becomes the key responder and implements UIKeyInput
.
https://developer.apple.com/reference/uikit/uikeyinput
It was implemented in 8.0, before the typeahead functionality on the iOS keyboard. I am updating it for 10.0 and it's not managing the interaction well.
- (void)deleteBackward {
NSString *text = self.codedLabel.text;
if (text.length > 0) {
text = [text substringToIndex:text.length-1];
}
self.codedLabel.text = text;
self.decodeLabel.text = [text stringByReplacingOccurrencesOfString:@"\n" withString:@" | "];
[self saveText:text];
}
- (BOOL)hasText {
NSString *text = self.codedLabel.text;
return (text.length > 0);
}
- (void)insertText:(NSString *)newtext {
NSString *text = self.codedLabel.text;
text = [text stringByAppendingString:newtext];
self.codedLabel.text = text;
self.decodeLabel.text = [text stringByReplacingOccurrencesOfString:@"\n" withString:@" | "];
[self saveText:text];
}
When one of the type ahead words is selected, insertText:
is invoked, but the newtext
value is always 0xa000000000000201
and the debug output is
(lldb) po newtext
(lldb) p newtext.length
(NSUInteger) $1 = 1