Skip to content

Instantly share code, notes, and snippets.

@stevemoser
Created August 24, 2012 01:52
Show Gist options
  • Save stevemoser/3444638 to your computer and use it in GitHub Desktop.
Save stevemoser/3444638 to your computer and use it in GitHub Desktop.
RestKit Post 2
#import "SMArticle.h"
#import <RestKit/RestKit.h>
@implementation SMArticle
@synthesize articleID,name;
+ (RKObjectMapping *)mapping {
RKObjectMapping* articleMapping = [RKObjectMapping mappingForClass:[SMArticle class]];
[articleMapping mapKeyPath:@"id" toAttribute:@"articleID"];
[articleMapping mapKeyPath:@"name" toAttribute:@"name"];
return articleMapping;
}
+ (RKObjectMapping *)serializationMapping {
RKObjectMapping* articleMapping = [RKObjectMapping mappingForClass:[SMArticle class]];
[articleMapping mapKeyPath:@"articleID" toAttribute:@"id"];
return articleMapping;
}
+ (void)routingWithRouter:(RKObjectRouter*)router
{
// Define a default resource path for all unspecified HTTP verbs
[router routeClass:[SMArticle class] toResourcePath:@"api/v1/articles/:articleID"];
[router routeClass:[SMArticle class] toResourcePath:@"api/v1/articles.json" forMethod:RKRequestMethodPOST];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment