我想不出以一种优雅的方式解析这个响应。我正在尝试将不同的字段类型与包含以下属性的对象匹配。
@property (nonatomic) NSString *name;
@property (nonatomic) NSString *address;
@property (nonatomic) NSString *city;
@property (nonatomic) NSString *postalcode;
@property (nonatomic) NSString *district;
@property (nonatomic) NSString *country;
在过去,我浏览了 Dictionary 该子字段与我搜索的字段相匹配。
{
"results" : [
{
"address_components" : [
{
"long_name" : "10",
"short_name" : "10",
"types" : [ "street_number" ]
},
{
"long_name" : "Warschauer Straße",
"short_name" : "Warschauer Straße",
"types" : [ "route" ]
},
{
"long_name" : "Friedrichshain",
"short_name" : "Friedrichshain",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Friedrichshain-Kreuzberg",
"short_name" : "Friedrichshain-Kreuzberg",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Berlin",
"short_name" : "Berlin",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Berlin",
"short_name" : "Berlin",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Germany",
"short_name" : "DE",
"types" : [ "country", "political" ]
},
{
"long_name" : "10243",
"short_name" : "10243",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Warschauer Straße 10, 10243 Berlin, Germany",
"geometry" : {
"location" : {
"lat" : 52.51329350,
"lng" : 13.45246930
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 52.51464248029150,
"lng" : 13.45381828029150
},
"southwest" : {
"lat" : 52.51194451970850,
"lng" : 13.45112031970850
}
}
},
"types" : [ "street_address" ]
}
],
"status" : "OK"
}