Tag: restkit 0.20

寻求针对浅层路由的最佳RestKit / CoreData映射和JSON结构的建议

我正在开发一个由(Rails)REST API(支持浅层路由)支持的CoreData iOS应用程序。 因为图中有很多对象,所以我希望REST GET不包含大量嵌套结果,而只是包含RestKit用于建立(故障)关系的引用。 然后,我将根据需要使用浅路由来请求单个(或一组)对象。 假设我有一对多(>)数据模型,如A > B,我有: RKEntityMapping *a_mapping = [RKEntityMapping mappingForEntityForName:@”A” inManagedObjectStore:managedObjectStore]; [a_mapping addAttributeMappingsFromDictionary:@{@”a_id” : @”aId”, …}]; a_mapping.identificationAttributes = @[@”aId”]; RKEntityMapping *b_mapping = [RKEntityMapping mappingForEntityForName:@”B” inManagedObjectStore:managedObjectStore]; [b_mapping addAttributeMappingsFromDictionary:@{@”b_id” : @”bId”, …}]; b_mapping.identificationAttributes = @[@”bId”]; [a_mapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@”bs” toKeyPath:@”bs” withMapping:b_mapping]]; 我有这些路线: NSIndexSet *statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful); RKResponseDescriptor *a_ResponseDescriptor; a_ResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:a_mapping method:RKRequestMethodGET pathPattern:@”/A/:aId” […]