Created
December 17, 2012 21:30
-
-
Save christian-smith/4322461 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET /users/self | |
{ | |
"users": { | |
"id": 329, | |
"username": "test1", | |
"blocks": [ | |
{ | |
"id": 111, | |
"created_at": "2012-12-17 21:06:22.005491", | |
"user": { | |
"id": 266, | |
"username": "test2", | |
} | |
} | |
], | |
} | |
} | |
GET /blocks | |
"blocked": [ | |
{ | |
"id": 111, | |
"created_at": "2012-12-17 21:06:22.005491", | |
"user": { | |
"id": 266, | |
"username": "test2", | |
} | |
} | |
//User Mapping | |
RKEntityMapping *userMapping = [RKEntityMapping mappingForEntityForName:@"User" inManagedObjectStore:managedObjectStore]; | |
userMapping.identificationAttributes = @[ @"id" ]; | |
[userMapping addAttributeMappingsFromArray:@[ @"id", @"username" ]; | |
//Block mapping | |
RKEntityMapping *blockMapping = [RKEntityMapping mappingForEntityForName:@"Block" inManagedObjectStore:managedObjectStore]; | |
[blockMapping addAttributeMappingsFromDictionary:@{ | |
@"id": @"blockID", | |
@"created_at": @"createdAt" | |
//Relationships | |
[blockMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"user" toKeyPath:@"user" withMapping:userMapping]]; | |
[userMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"blocks" toKeyPath:@"blocks" withMapping:blockMapping]]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment