Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.