I am currently using NSDataDetectors to find links:
-(void)setBodyText
{
NSString* labelText = [[message valueForKey:@"body"]gtm_stringByUnescapingFromHTML];
NSDataDetector *linkDetector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil];
NSArray *matches = [linkDetector matchesInString:labelText options:0 range:NSMakeRange(0, [labelText length])];
for (NSTextCheckingResult *match in matches) {
if ([match resultType] == NSTextCheckingTypeLink) {
NSURL *url = [match URL];
[bodyLabel addCustomLink:url inRange:[match range]];
NSLog(@"found URL: %@", url);
}
}
[bodyLabel setText:labelText];
[Utils alignLabelWithTop:bodyLabel];
}
How can I use NSDataDetectors to parse @ for example:
"Hello @sheehan, you are cool"
I want it to be able to detect @sheehan
NOTE: I want to use NSDataDetector's or regex pattern matching. No custome Labels or controls etc.