Has anyone had any luck using NSDataDetector on iOS to match flight information? It looks really amazingly powerful, except I can't get it to work at all.
Here's what I'm trying:
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:(NSTextCheckingTypes)NSTextCheckingTypeTransitInformation error:&error];
[detector enumerateMatchesInString:string
options:0
range:NSMakeRange(0, [string length])
usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
NSLog(@"Detected: %@, %@", result, [result URL]);
}
I'm trying this on a variety of strings, including the body of every calendar entry I could find in my calendar that had flight info in it.
Examples:
- "UA460 SFO to YVR [Flight] 6/12/2013 United Airlines(UA) #460 dep SFO 7:57pm PDT arr YVR 10:14pm PDT; Ticket #0162360127882, Ticket #0162360127883; conf #K5XBXY; Note:, Seats:---/30A , Seats:---/30B "
- "Pick up Laura at Airport UA 1255"
- "Lufthansa 1128 Business (C) | Seat 07F Frankfurt Barcelona 2 h 0 m 679miles
FRA 1:15pm BCN 3:15pm , Arrives on Fri Oct/5/2012
Lufthansa 1128 Business (C) | Seat 07F | Confirm or change seats with the airline*"
But none of these match. If I change data detector types to include NSTextCheckingTypePhoneNumber or NSTextCheckingTypeLink, those match great. But I can't get flight data.
Any one have any luck with this?
Flight numbers are detected on OS X, but not on iOS. Please file a bug with Apple to either get the documentation updated, or to get support for this on iOS.