Skip to content

Instantly share code, notes, and snippets.

@ivan3bx
Created April 15, 2014 05:36
Show Gist options
  • Save ivan3bx/2f168df23c91399aa884 to your computer and use it in GitHub Desktop.
Save ivan3bx/2f168df23c91399aa884 to your computer and use it in GitHub Desktop.
Just a snippet of code for detecting a possible match. This seems inefficient for just single-character matches..
- (void)textDidChange:(NSNotification *)aNotification
{
NSTextView *textView = self.detailTextView;
NSString *contents = textView.textStorage.string;
NSRange selectionRange = textView.selectedRange;
if (selectionRange.length == 0 && contents.length > 0) {
NSString *possibleMatch = [contents substringWithRange:NSMakeRange(selectionRange.location - 1, 1)];
if ([possibleMatch isEqualToString:@"{"]) {
[textView complete:nil];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment