The NSDataDetector class is a specialized subclass of the NSRegularExpression class designed to match data detectors. It is available in iOS 4.0 and later and available in OS X v10.7 and later. The issues related with NSDataDetector should be tagged with question with related iOS or OS X platforms.
The NSDataDetector
class makes it easy to detect URLs inside a string using just a few lines of code. NSDataDetector
class can match dates, addresses, links, phone numbers and transit information.
The results of matching content is returned as
NSTextCheckingResult
objects. However, theNSTextCheckingResult
objects returned byNSDataDetector
are different from those returned by the base classNSRegularExpression
. Results returned byNSDataDetector
will be of one of the data detectors types, depending on the type of result being returned, and they will have corresponding properties. For example, results of typeNSTextCheckingTypeDate
have a date, timeZone, and duration; results of typeNSTextCheckingTypeLink
have a URL, and so forth.Source: NSDataDetector Class Reference
Example:
NSError *error = NULL;
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink|NSTextCheckingTypePhoneNumber
error:&error];