我从以下网址加载数据:
https://myserver.com/api/kitchens/0af569e6-3e7d-4d6d-b8ca-7a70f93160c9/recipes/18488b51-04e0-4146-8ac6-05106db14024
数据如下:
{
"recipe": {
"id": "18488b51-04e0-4146-8ac6-05106db14024",
"kitchen-id": "0af569e6-3e7d-4d6d-b8ca-7a70f93160c9",
"rating": "",
"title": "My recipe",
"author": “John”,
"date": "2014-05-10",
"location": “Paris,
"servings": 4,
"customer-rating": 5.0,
"ingredients": [
]
}
}
我可以映射数据,这样我的映射就可以了。但是,只要我指定一个模式,我就不再获得任何数据映射。我的模式出了什么问题?
这里有一个比较:
PATTERN
/api/kitchens/:kitchenID/recipes/:recipeID
URL PATH
/api/kitchens/0af569e6-3e7d-4d6d-b8ca-7a70f93160c9/recipes/18488b51-04e0-4146-8ac6-05106db14024
我的映射代码
RKEntityMapping *mapping = [RKEntityMapping mappingForEntityForName:@"Recipe" inManagedObjectStore:self.service.managedObjectStore];
NSDictionary *map = @{
@"id": @"id",
@"title": @"title",
@"rating": @"rating",
@"date": @"createdOn",
@"author": @"author",
@"servings": @"servings",
@"customer-rating": @"customerRating",
};
[mapping addAttributeMappingsFromDictionary:map];
result.identificationAttributes = @[@"id"];
// This does not work
NSString *pattern = @"/api/kitchens/:kitchenID/recipes/:recipeID"
// This works
NSString *pattern = nil;
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:mapping method:RKRequestMethodAny pathPattern:pattern keyPath: @“recipe” statusCodes:statusCodes];