Ad

Our DNA is written in Swift
Jump

Radar: NSDataDetector Bug

This has been bugging me for quite some time, since some of my address book contacts are affected. NSDataDetector does not properly handle addresses which have more than 2 numbers with one slash.

Previously, this issue was compounded by another issue in the geocoder which would take the apartment number (instead of the street number) for determining the geographic position. To workaround this I had to add another address to some of my contacts that didn’t have the apartment number. This seems to have been fixed in iOS 8.3, but NSDataDetector is still broken.

Filed as rdar://20549548 and on Open Radar

Address Detection broken for addresses with more than one slash

Summary

I live in Vienna, Austria. Many people live in large apartment complexes which are subdivided into multiple blocks. Typically addresses for such apartments include the street number + the block number + the apartment number. In taller blocks people often also include the floor level number. All of these numbers are separated by slashes.

NSDataDetector is unable to deal with those addresses and aborts parsing once it encounters the second slash in the street number. This results in incomplete address component dictionaries being returned. Only the street address is filled in and only with the first two numbers with the slash in between them.

The provided sample app shows the issue in two ways:

  1. It has 3 styles of address in UITextView and there you can see – marked in blue – the detected addresses
  2. For each address the ViewController.m outputs the address component dictionary.

Steps to Reproduce

  1. Launch the provided sample app in Simulator
  2. Look at the marked addresses in the text views
  3. Look at the NSLog output

Expected Results

  • In all 3 cases the entire address should be detected and marked
  • In all 3 cases the expected results are 4 items in the dictionary

Actual Results

  • only the first address is completely marked and has 4 components in the detected address dictionary
  • the second and third address are only marked until before the second slash
  • the second and third addresses only have a street entry in the address dictionary

Notes

As a workaround I need to have extra – incomplete – addresses for people with more than two numbers in their postal address, so that I can navigate there.

The referenced sample app is “DataDetectorAddressBug” at https://github.com/cocoanetics/RadarSamples

DataDetector Bug Sample


Categories: Bug Reports

1 Comment »

Trackbacks

  1. Radar: CLGeoCoder Bug | Cocoanetics

Leave a Comment