Created
April 27, 2012 03:41
-
-
Save Lordnibbler/2505573 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
- (void)setupObjectMapping { | |
// RKObjectMapping* channelMapping = [RKObjectMapping mappingForClass:[Channel class]]; | |
// [channelMapping mapKeyPath:@"id" toAttribute:@"identifier"]; | |
// [channelMapping mapKeyPath:@"name" toAttribute:@"name"]; | |
// //[channelMapping mapKeyPath:@"created_at" toAttribute:@"createdAt"]; | |
// //[channelMapping mapKeyPath:@"updated_at" toAttribute:@"updatedAt"]; | |
// [channelMapping mapKeyPath:@"num_of_listeners" toAttribute:@"numOfListeners"]; | |
RKObjectMapping* channelMapping = [RKObjectMapping mappingForClass:[Channel class] ]; | |
channelMapping.forceCollectionMapping = YES; | |
[channelMapping mapKeyOfNestedDictionaryToAttribute:@"identifier"]; | |
[channelMapping mapKeyPath:@"(identifier).name" toAttribute:@"name"]; | |
[channelMapping mapKeyPath:@"(identifier).num_of_listeners" toAttribute:@"numOfListeners"]; | |
//object mapping for GETs | |
[[RKObjectManager sharedManager].mappingProvider setMapping:channelMapping forKeyPath:@"channels"]; | |
//set up object serialization for POSTing back to rails | |
RKObjectMapping* channelSerializationMapping = [channelMapping inverseMapping]; | |
[RKObjectManager sharedManager].serializationMIMEType = RKMIMETypeJSON; | |
//manager.acceptMIMEType = RKMIMETypeJSON; | |
[[RKObjectManager sharedManager].mappingProvider setSerializationMapping:channelSerializationMapping forClass:[Channel class]]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment