Reverse Geocode Response = {
error = "Unable to geocode";
}
Reverse Geocode Response = {
address = {
city = "San Francisco";
country = "United States of America";
"country_code" = us;
county = "San Francisco City and County";
electronics = "Apple Store";
neighbourhood = Chinatown;
pedestrian = "Stockton Street";
0postcode = 94104;
state = California;
};
boundingbox = (
"37.7857515",
"37.7859644",
"-122.4066919",
"-122.406347"
);
"display_name" = "Apple Store, Stockton Street, Chinatown, San Francisco, San Francisco City and County, California, 94104, United States of America";
lat = "37.7858585";
licence = "Data \U00a9 OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright";
lon = "-122.406519260264";
"osm_id" = 147689077;
"osm_type" = way;
"place_id" = 97545943;
}
i Erfolg und scheitern Antwort von APIwie sie beheben Json in schnellen 2,3 und XCode 8,1
do {
let result = try? NSJSONSerialization.JSONObjectWithData(response, options:.AllowFragments)
// print("Reverse Geocode Response = \(result) ")
if result != nil {
let address:Dictionary = result!["address"] as! Dictionary<String,AnyObject>
if address.count > 0 {
country = address["country"] as! String //country_code
postalCode = address["postcode"] as! String
print("Country = \(country) ,Postal Code = \(postalCode)")
}
}else{
print("Error")
}
}catch{
print("Error with Json \(error)")
}
ich bekam Absturz gescheitert Absturz Reaktionszeit bekam abstürzt. bitte helfen, diesen Absturz zu finden.
wenn ich bekam error = "Geocode nicht möglich"; Diese Antwort bekam ich Fehler WIE diese Art von Situation zu lösen Danke im Vorraus
können Sie die Fehlermeldung posten? –
Denken Sie daran, jede Verwendung von '!' In Ihrem Code bedeutet "hier abstürzen". – rmaddy