Adding mapping error: Expected an object mapping for class of type...

370 views
Skip to first unread message

Benjamin Willard

unread,
Dec 30, 2011, 9:54:11 PM12/30/11
to RestKit
I have an error here that I am trying to figure out what I can do make
it work...

First of all The data that I get is not always the same class object.
For example... When login is called it can return a few things...
(LoginResponse) or (LogResponse). These two are shared one is to give
successful login and the other is to handle an error that was
performed when this happens I perform an Alert to the current user.

I am getting a Adding mapping error: Expected an object mapping for
class of type 'LoginRequest', provider returned one for 'LogResponse'.

If I do successful it gives same error but:

I am getting a Adding mapping error: Expected an object mapping for
class of type 'LoginRequest', provider returned one for
'LoginResponse'.

How can I do this correctly in the mapping so that it knows that
LoginRequest can accept both LogResponse and LoginResponse...???

Ben

Ray Fix

unread,
Dec 30, 2011, 10:28:08 PM12/30/11
to res...@googlegroups.com

When you post your login object, use the one that takes the loader block configuration.  Then set loader.targetObject = nil;  I think this will make it map using the rootKeyPaths that your response returns.  (Someone please correct me if I am mistaken.)

 [[RKObjectManager sharedManager] postObject:loginObject 
   delegate:self block:^(RKObjectLoader* loader) {
   loader.resourcePath = @"/login";
   loader.targetObject = nil;

Benjamin Willard

unread,
Dec 30, 2011, 10:48:52 PM12/30/11
to RestKit
Thanks a lot Ray, that really helped save me a headache and thanks for
the quick response...

Basically i made it so that my Web Service allows me to send KVC
concept that helps solves all problems for the future as I have
wrapper methods going towards my "Process" which handles ALL requests
and handles all responses...

Ben
Reply all
Reply to author
Forward
0 new messages