I have upgraded to xcode 7 beta 6 as iOS 9 will be on us soon. I was very pleased that my code converted without too much hassle except for one exception.
It seems that the placemark.addressDictionary
has been changed to [NSObject: AnyObject]
?
This was my code in xCode 6 for a map search
for item in response.mapItems as! [MKMapItem] {
var placeMarkAddress = item.placemark.addressDictionary
let street:String = placeMarkAddress["Street"] != nil ? placeMarkAddress["Street"] as! String : ""
}
This no longer works as placeMarkAddress
is now [NSObject: AnyObject]
?
How do I get the value (AnyObject
) out by referencing the NSObject
by name?
I've tried this in xcode7
for item in response!.mapItems {
var placeMarkAddress = item.placemark.addressDictionary
for placeMarkAddress in placeMarkAddresses!{
print(placeMarkAddress)
}
}
The output I get is this.
(FormattedAddressLines, [440 Castro St, San Francisco, CA 94114-2020, United States])
(Street, 440 Castro St)
(SubAdministrativeArea, San Francisco)
(Thoroughfare, Castro St)
(ZIP, 94114)
(Name, 440 Castro)
(City, San Francisco)
(PostCodeExtension, 2020)
(Country, United States)
(State, CA)
(SubLocality, Castro)
(SubThoroughfare, 440)
(CountryCode, US)
This maybe obvious to some of you but I'm still a bit of a newbie to iOS development.