NSDataDetector phone number result

Originator:steve_w101
Number:rdar://15561004 Date Originated:30-Nov-2013
Status:Open Resolved:
Product:iOS SDK Product Version:7.0.4
Classification: Reproducible:Always
 
Summary:
When using an NSDataDetector with the NSTextCheckingTypePhoneNumber type included, it will (seemingly incorrectly) detect the text "phone number" before a valid phone number.

Steps to Reproduce:
NSError *error = nil;
NSDataDetector *dataDetector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypePhoneNumber
                                                               error:&error];

NSArray *stringsToTest = @[
                           @"testing phone number 0123 4567891",
                           @"testing some other number 0123 4567892",
                           @"phone number 0123 4567893",
                           @"blah blah 0123 4567894",
                           @"testing telephone number 0123 4567895"
                           ];

for (NSString *string in stringsToTest)
{
    [dataDetector enumerateMatchesInString:string
                                   options:0
                                     range:NSMakeRange(0, string.length)
                                usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
                                    NSLog(@"%@", result.phoneNumber);
                                }];
}

Expected Results:
I'd expect the following numbers to be detected and be the sole content of result.phoneNumber:
0123 4567891
0123 4567892
0123 4567893
0123 4567894
0123 4567895

Actual Results:
Instead the NSLog call prints out the following, not in log 1 and 3 the text "phone number" before the actual number:

2013-11-24 19:04:26.000 PhoneNumberDetector[21874:70b] phone number 0123 4567891
2013-11-24 19:04:26.000 PhoneNumberDetector[21874:70b] 0123 4567892
2013-11-24 19:04:26.000 PhoneNumberDetector[21874:70b] phone number 0123 4567893
2013-11-24 19:04:26.000 PhoneNumberDetector[21874:70b] 0123 4567894
2013-11-24 19:04:26.001 PhoneNumberDetector[21874:70b] 0123 4567895

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!