Reputation: 119
this used to work until i upgraded to xcode 7.3 a few days ago. It compiles and runs fine up until I need to archive the project. During the archive I get a "Ambiguous Use of Subscript" error on the second question mark?
if let address = placemark.addressDictionary?["FormattedAddressLines"]?[1]
{
//do something
}
Any idea on how to correct this?
Upvotes: 2
Views: 391
Reputation: 7310
Ambiguous Use of Subscript
means that the compiler could not infer which subscript you want to use. It looks like the type of placemark.addressDictionary?["FormattedAddressLines"]
returns is unclear to the compiler.
Try breaking it up like:
let addressLines = placemark.addressDictionary?["FormattedAddressLines"] as? [String]
if let address = addressLines?[1]
{
//do something
}
I haven't tried this so I'm not 100% on the syntax. But this would force the type to be a string array which (I think) is what you're expecting to get back.
Upvotes: 1