2015-11-25 28 views
9

Ho la seguente riga che funzionava in iOS 8 in Swift.Conversione [NSObject, AnyObject] in [String, AnyObject] in Swift

let placemark = placemarks![0] as? CLPlacemark 

let destinationPlacemark = MKPlacemark(

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

) 

ma ora mi dà la seguente eccezione:

Impossibile convertire il valore di tipo '[NSObject: ANYOBJECT]?' Attendere il tipo di argomento '[String: AnyObject]?'

Come posso farlo?

+3

Prova a trasmettere 'segnaposto? .addressDictionary come? [String: AnyObject] ' – Leo

+0

Questo ha fatto il trucco! Grazie mille :) –

+0

Dal momento che funziona, invierò una risposta – Leo

risposta

8

È necessario lanciare il tipo da [String : AnyObject]

placemark?.addressDictionary as? [String:AnyObject] 
Problemi correlati