简体   繁体   中英

Converting [NSObject, AnyObject] to [String, AnyObject] in Swift

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?

您需要将类型[String : AnyObject][String : AnyObject]

placemark?.addressDictionary as? [String:AnyObject]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM