0

次の JSON からマッピングを作成するのを手伝ってください

{
meta: {}
notifications: []
response: {
suggestedFilters: {}
suggestedRadius: 922
headerLocation: "Manhattan"
headerFullLocation: "Manhattan"
headerLocationGranularity: "city"
totalResults: 
suggestedBounds: {}
groups: [
{
type: "Recommended Places"
name: "recommended"
items: [
{
reasons: {}
venue: {
id: "430d0a00f964a5203e271fe3"
name: "Brooklyn Bridge Park"
contact: {}
location: {}
categories: []
verified: 
stats: {}
likes: {}
like: 
rating: 
hours: {}
specials: {}
photos: {}
hereNow: {}
}
tips: []
referralId: "e-0-430d0a00f964a5203e271fe3-0"
}
{

プロパティを持つ Venue オブジェクトへ

@property (nonatomic, copy) NSString *ID;
@property (nonatomic, copy) NSString *name;

応答>グループ>会場> idを「id」に、応答>グループ>会場>名前を「名前」にマッピングする必要があります

私はこれを書きます

NSIndexSet *statusCodeSet = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful);

    RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:[MappingProvider venueMapping]
                                                                                            method:RKRequestMethodGET
                                                                                       pathPattern:@"/v2/venues/explore"
                                                                                           keyPath:@"response"
                                                                                       statusCodes:statusCodeSet];

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/venues/explore?ll=40.7,-74&oauth_token=%@",
                                       [[DataManager sharedManager] baseURL], [[DataManager sharedManager] anonymusUserAccessToken]]];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    RKObjectRequestOperation *operation =  [[RKObjectRequestOperation alloc] initWithRequest:request
                                                                         responseDescriptors:@[responseDescriptor]];

    [operation setCompletionBlockWithSuc.....

しかし、それは機能していません

ありがとうございました

4

1 に答える 1