This is how I did it using NSPredicate
. This tells you the current @mention word that's being edited/typed. Hope this helps.
- (void)textViewDidChange:(UITextView *)textView
{
_words = [self.textView.text componentsSeparatedByString:@" "];
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH[cd] '@'"];
NSArray* names = [_words filteredArrayUsingPredicate:predicate];
if (_oldArray)
{
NSMutableSet* set1 = [NSMutableSet setWithArray:names];
NSMutableSet* set2 = [NSMutableSet setWithArray:_oldArray];
[set1 minusSet:set2];
if (set1.count > 0)
NSLog(@"Results %@", set1);
}
_oldArray = [[NSArray alloc] initWithArray:names];
}