A String not an object, so you need to send it to NSString . I would recommend the following syntax for creating and deploying it at the same time. Don't worry about comparing it to a variable of type String! because they are compatible. This will work:
func formatPlacemark(placemark: CLPlacemark) -> (String, String) { if let street = placemark.addressDictionary["Street"] as? NSString { if placemark.name == street {
This has additional advantages: if "Street" is not a valid key in your dictionary, or if the type of the object is something other than NSString , it will not crash. He just won't go into the block.
If you really want the street to be String , you could do this:
if let street:String = placemark.addressDictionary["Street"] as? NSString
but in this case he wonβt buy anything.
source share