I'm using CLGeocoder
for reverse geolocation and get array of CLPlacemark
. When I use GPS outside the US (i.e. -27,127) and then access placemark.postalCode
, the app crashes with:
"fatal error: unexpectedly found nil while unwrapping an Optional value".
It seems, that placemark.postalCode
is nil
where no postal code is available. But postalCode
return type in Swift is String!
:
var postalCode: String! { get } // zip code, eg. 95014
So I can't even test is for nil
, because the crash is caused by the getter of postalCode
.
Any ideas how to prevent this crash? Thank you!