9
votes

I have the following line which used to work in iOS 8 in Swift.

 let placemark = placemarks![0] as? CLPlacemark

 let destinationPlacemark = MKPlacemark(

     coordinate: placemark!.location!.coordinate, 
     addressDictionary: placemark?.addressDictionary

 )

but now it gives me the following exception:

Cannot convert value of type '[NSObject : AnyObject]?' to expected argument type '[String : AnyObject]?'

How can I do that?

1
Try casting placemark?.addressDictionary as? [String:AnyObject] - Leo
That did the trick! Thanks a lot :) - john doe
Since it works,i will post an answer - Leo

1 Answers

8
votes

You need to cast the type to [String : AnyObject]

placemark?.addressDictionary as? [String:AnyObject]