Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6149359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:26:21+00:00 2026-05-23T19:26:21+00:00

I have the DiscussionBoard app working for RestKit and I am porting the DBUser

  • 0

I have the DiscussionBoard app working for RestKit and I am porting the DBUser class to my application. The only difference being my app will not be using CoreData.

I am able to POST the user object and have new user id and authentication_token returned to my app. The problem is that the response is not being serialized into
a user object. Why won’t request:didLoadResponse:response return a User object but I can see the correct json in signUpWithDelegate:delegate

And you can see here I can’t get objectLoader:didLoadObjects to return with serialized objects? Why doesn’t the object get serialized?

  [12881:207]Loaded payload: {"user":{"id":"85","authentication_token":"_Udl98OO-xgmZOOJM26w","email":"ffff@adsfadfa.com"}}
  [12881:207] _____    objectLoader didLoadObjects   (
  )
  [12881:207] loginWasSuccessful (null)

AppDelegate.m

RKObjectManager *objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://spoonbook-2.local:3000/"];
[objectManager.router routeClass:[RKUser class] toResourcePath:@"/api/v1/authentication/create.json" forMethod:RKRequestMethodPOST];
// User
RKObjectMapping *userMapping = [RKObjectMapping mappingForClass:[RKUser class]];
[userMapping mapKeyPath:@"id" toAttribute:@"userId"];
[userMapping mapAttributes:@"email", nil];
[userMapping mapAttributes:@"authentication_token", nil];    
[objectManager.mappingProvider setObjectMapping:userMapping forKeyPath:@"user"];

RegisterViewController.m

  -(IBAction)handleLoginClick:(id)sender
  {
      NSLog(@"handleLoginClick");
      RKUser *user = [[[RKUser alloc] init] retain];    
      [user createWithEmail:_regEmailTF.text andPassword:_regPasswordTF.text delegate:self];
      [user release];
  }

User.m

#import "RKUser.h"
#import <RestKit/RestKit.h>
static NSString* const kDBUserCurrentUserIDDefaultsKey = @"kDBUserCurrentUserIDDefaultsKey";
// Current User singleton
static RKUser* currentUser = nil;
@implementation RKUser
@synthesize userID = _userID;
@synthesize email = _email;
@synthesize password = _password;
@synthesize passwordConfirmation = _passwordConfirmation;
@synthesize delegate = _delegate;
@synthesize authentication_token = _authentication_token;


-(void)createWithEmail:(NSString *)username andPassword:(NSString *)password delegate:(NSObject<UserAuthenticationDelegate> *)delegate
{
  _delegate = delegate;
    RKObjectManager*objectManager = [RKObjectManager sharedManager];
    RKObjectLoader* objectLoader = [objectManager objectLoaderWithResourcePath:@"/api/v1/authentication/create.json" delegate:self];
    objectLoader.method = RKRequestMethodPOST;
    objectLoader.params = [NSDictionary dictionaryWithKeysAndObjects:@"user[email]", username, @"user[password]", password, @"user[password_confirmation]", password, nil];
    objectLoader.targetObject = self;
    // try adding a userMapping?
    RKObjectMapping *userMapping = [objectManager.mappingProvider objectMappingForKeyPath:@"user"];
    objectLoader.objectMapping = userMapping;
    // TODO: Temporary to work around bug in Rails serialization on the Heroku app
    objectLoader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForKeyPath:@"user"];
    [objectLoader send];    
}


- (void)request:(RKRequest*)request didLoadResponse:(RKResponse*)response 
{
    NSLog(@"ReviewFormViewController Loaded payload: %@", [response bodyAsString]);
}

- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray *)objects
{
    // NOTE: We don't need objects because self is the target of the mapping operation
    NSLog(@"_____    objectLoader didLoadObjects   %@", objects);
    if ([objectLoader wasSentToResourcePath:@"/api/v1/authentication/login.json"]) {
        // Login was successful
        [self loginWasSuccessful];
    }  else if ([objectLoader wasSentToResourcePath:@"/api/v1/authentication/create.json"]) { 
        // Sign Up was successful
        if ([self.delegate respondsToSelector:@selector(userDidSignUp:)]) {
            [self.delegate userDidSignUp:self];
        }
        // Complete the login as well
        [self loginWasSuccessful];      
    }
}

- (void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError*)error {  
  ...snip...
}

- (void)loginWasSuccessful {
  ...snip...
}    
@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:26:22+00:00Added an answer on May 23, 2026 at 7:26 pm

    I think you need to use this in order to be able to map the response.

    /**
     Send the data for a mappable object by performing an HTTP POST. The data returned in the response will be mapped according
     to the object mapping provided.
     */
    - (RKObjectLoader*)postObject:(id<NSObject>)object mapResponseWith:(RKObjectMapping*)objectMapping delegate:(id<RKObjectLoaderDelegate>)delegate;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have started playing with Xcode 4.2, and created a single page application using storyboard
Have done some working samples using Backbone Router, but is there a way to
Have I understod the following right? font-family:sans-serif; Above will result in the default sans-serif
Have just started converting an existing job tracking system into an ASP.NET MVC application.
Have a singleton class for BNRItemStore, but when I tried to call it, I
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have a web app that create groups. Each group gets their own discussion
I am writing a discussion board software that will have avatar images for the
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.