我想在 Google Places Api Photos 中映射对象
"photos" : [
{
"height" : 1224,
"html_attributions" : [
"\u003ca href=\"https://plus.google.com/105663944571530352563\"\u003eJoshua Gilmore\u003c/a\u003e"
],
"photo_reference" : "CnRoAAAAzuH4E1LVJHMdXNYbewoxcPE-qHizCE6pmOGjckeaCTKSL7xGVzLuwGxu7kx44bCWIZinMx4jkd8eenALB7w7jNRFrzE3hip2ld7096SI9D4sE2WpXQ1QH-iTQm7qhx4i6QSGGeXKjA9SfT4N6krwzRIQr1mulgyuKHP-2s_TJWIahhoUgxfccds3VAH2bj_CIQYzbAQZRhc",
"width" : 1632
}
],
我尝试使用此代码,但照片仍然为零
地方类
@interface Place : NSObject
@property (nonatomic,strong) Geometry * geometry;
@property (nonatomic,strong) NSString * icon;
@property (nonatomic,strong) NSString * placeID;
@property (nonatomic,strong) NSString * name;
@property (nonatomic,strong) OpeningHours * opening_hours;
@property (nonatomic,strong) NSString * price_level;
@property (nonatomic,strong) NSString * rating;
@property (nonatomic,strong) NSString * vicinity;
@property (nonatomic,strong) NSArray *photos;
@property (nonatomic,strong) NSString *reference;
@end
照片课
#import <Foundation/Foundation.h>
@interface Photos : NSObject
@property (nonatomic,strong) NSNumber *height;
@property (nonatomic,strong) NSString *html_attributions;
@property (nonatomic,strong) NSString *photo_reference;
@property (nonatomic,strong) NSNumber *width;
@end
我映射:
RKObjectMapping *placeMapping = [RKObjectMapping mappingForClass:[Place class]];
[placeMapping addAttributeMappingsFromDictionary:@{
@"icon" : @"icon",
@"id" : @"placeID",
@"name" : @"name",
@"reference" : @"reference",
@"price_level" : @"price_level",
@"rating" : @"rating",
@"vicinity" : @"vicinity",
}];
RKObjectMapping* photosMapping = [RKObjectMapping mappingForClass:[Photos class]];
[photosMapping addAttributeMappingsFromArray:@[@"height",@"photo_reference",@"html_attributions",@"width"]];
[placeMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"photos"
toKeyPath:@"photos"
withMapping:photosMapping]];
我不知道如何将照片映射为 Place Class 中的数组。任何人都可以帮助我吗?