Guest User

Untitled

a guest
Jan 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. @interface LoginRequest : NSObject
  2. {
  3. NSString* _deviceId;
  4. }
  5.  
  6. @property (nonatomic, retain) NSString* deviceId;
  7.  
  8. @end
  9.  
  10. objectManager.serializationMIMEType = RKMIMETypeFormURLEncoded;
  11.  
  12. RKObjectMapping* pmsg = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];
  13. [pmsg mapKeyPath: @"deviceId" toAttribute:@"DeviceId"];
  14.  
  15. RKObjectMapping* pmsgSerializeMapping = [pmsg inverseMapping];
  16.  
  17. [objectManager.mappingProvider setSerializationMapping:pmsgSerializeMapping forClass:[LoginRequest class]];
  18.  
  19. [objectManager.router routeClass:[LoginRequest class] toResourcePath:@"/login" forMethod:RKRequestMethodPOST];
  20.  
  21. *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<LoginRequest 0x8c9c980> valueForUndefinedKey:]: this class is not key value coding-compliant for the key DeviceId.'
  22.  
  23. RKObjectManager *objectManager = [RKObjectManager sharedManager];
  24.  
  25. LoginRequest* request = [LoginRequest alloc];
  26. request.deviceId = @"Test";
  27.  
  28. [objectManager postObject:request delegate: self];
  29.  
  30. RKObjectMapping* pmsg = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];
  31. [pmsg mapAttributes:@"DeviceId", nil];
  32.  
  33. [objectManager.mappingProvider setSerializationMapping:pmsg forClass:[LoginRequest class]];
  34.  
  35. [objectManager.router routeClass:[LoginRequest class] toResourcePath:@"/login" forMethod:RKRequestMethodPOST];
Add Comment
Please, Sign In to add comment