Skip to content

Instantly share code, notes, and snippets.

@fernandolopes
Last active December 24, 2015 02:19
Show Gist options
  • Select an option

  • Save fernandolopes/6730224 to your computer and use it in GitHub Desktop.

Select an option

Save fernandolopes/6730224 to your computer and use it in GitHub Desktop.
@implementation Cliente
+(RKObjectMapping *)clienteResponseMapping{
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[self class]];
[mapping addAttributeMappingsFromDictionary:@{
@"id": @"clienteID",
@"fbID": @"fbID",
@"nome": @"nome",
@"sobrenome": @"sobrenome",
@"email": @"email",
@"sexo": @"sexo",
@"dataNascimento" : @"dataNascimento"
}];
return mapping;
}
@end
-(void) sendServerUser{
// RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:[Cliente clienteResponseMapping] objectClass:[Cliente class] rootKeyPath:@"cliente"];
//Para nessa linha
RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:[Cliente clienteResponseMapping] objectClass:[Cliente class] rootKeyPath:@"clientes" method:RKRequestMethodPOST];
NSError* error;
NSDictionary *parameters = [RKObjectParameterization parametersWithObject:self.cliente requestDescriptor:requestDescriptor error:&error];
// Serialize the object to JSON
NSData *JSON = [RKMIMETypeSerialization dataFromObject:parameters MIMEType:RKMIMETypeJSON error:&error];
NSLog(@"%@",JSON);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment