两个端点结果之间的外键映射RESTKIT核心数据

时间:2013-08-02 10:21:10

标签: iphone ios ipad core-data restkit

是否有可能使用外键加入两个终点结果。

End Point 1 :
{"series":[{"id":2,"name":"My Series","role":"student","student_id":15,"instructor_ids":[13],"sequential":false,"series_id":1,"user_assignment_ids":[3,4]}]} 

End Point 2 :
{"Assignments":[{ "id":3,"Name":"Assignment1", "seriesID":2},{ "id":4,"Name":"Assignment1","seriesID":2},{ "id":6,"Name":"Assignment1","seriesID":null}]}

在上面的两个终点我有外键“user_assignment_ids”。

@class UserAssignment;
@interface UserSeries : NSManagedObject

@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSString * role;
@property (nonatomic, retain) NSNumber * sequential;
@property (nonatomic, retain) NSNumber * seriesID;
@property (nonatomic, retain) NSNumber * studentID;
@property (nonatomic, retain) id userAssignmentIDS;
@property (nonatomic, retain) NSSet *userAssignment;
@end

@interface UserSeries (CoreDataGeneratedAccessors)

- (void)addUserAssignmentObject:(UserAssignment *)value;
- (void)removeUserAssignmentObject:(UserAssignment *)value;
- (void)addUserAssignment:(NSSet *)values;
- (void)removeUserAssignment:(NSSet *)values;

@end

@class UserSeries;

@interface UserAssignment : NSManagedObject

@property (nonatomic, retain) NSNumber * assignmentID;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSNumber * seriesID;
@property (nonatomic, retain) UserSeries *userSeries;

@end

任何人都可以告诉我使用外键进行两个端点连接的可能方法吗?

1 个答案:

答案 0 :(得分:0)

使用RKConnectionDescription执行外键映射。文档页面here上有许多示例和指南。