Is it possible to check whether or not a CLPlacemark's
name is a street address?
I would like to display the name if it is a shopping center, theme park, school, or something else interesting, but not if it is a street address.
I was thinking about using a regex such as this to check if the name is a street address
^\d+ ([a-zA-Z0-9'-] ?)+$
But I feel like this won't always work, especially in other countries.
Is there any way to check if a CLPlacemark's name is a street address, like checking the size of the placemark, or will I have to use a third-party library?
Try checking the name
against the CLPlacemark's thoroughfare
(street) and subThoroughfare
(street number).
var placemark: CLPlacemark
if placemark.name.rangeOfString(placemark.thoroughfare) != nil
&& placemark.name.rangeOfString(placemark.subThoroughfare) != nil {
println("Name is likely the same as address")
} else {
println("Name is distinct from street address")
}