9

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?

3
  • 3
    Try casting placemark?.addressDictionary as? [String:AnyObject] Commented Nov 25, 2015 at 3:56
  • That did the trick! Thanks a lot :) Commented Nov 25, 2015 at 4:07
  • Since it works,i will post an answer Commented Nov 25, 2015 at 4:13

1 Answer 1

8

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

placemark?.addressDictionary as? [String:AnyObject]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.