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

  • SEARCH
  • Home
  • 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 8641861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:38:19+00:00 2026-06-12T11:38:19+00:00

So I am trying to get back an array of Leaderboard objects from a

  • 0

So I am trying to get back an array of Leaderboard objects from a database using rest calls. didLoadObjects returns 0 objects even though the mapping seems correct:

 RKObjectManager *svc = [RKObjectManager sharedManager];
 NSString *resourcePath = leaderboardResourcePath;
 RKObjectMapping* mapping = [svc.mappingProvider objectMappingForClass:[Leaderboard class]];
 RKObjectLoader *loader = [[RKObjectManager sharedManager] loadObjectsAtResourcePath:resourcePath objectMapping:mapping delegate:self];

Here is the didLoadObjects method

- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects { 
    if ([objectLoader.resourcePath isEqualToString:leaderboardResourcePath])
    {
        @synchronized(standings)
        {
             standings = objects;
        }
    }
}    

Here is the mapping code:

+ (void)setMappings
{
    //Standings mapping
    RKObjectMapping* leaderboardMapping = [RKObjectMapping mappingForClass:[Leaderboard class]];
    [leaderboardMapping mapKeyPath:@"uname" toAttribute:@"uname"];
    [leaderboardMapping mapKeyPath:@"geo" toAttribute:@"geo"];
    [leaderboardMapping mapKeyPath:@"week" toAttribute:@"week"];
    [leaderboardMapping mapKeyPath:@"year" toAttribute:@"year"];
    [leaderboardMapping mapKeyPath:@"pts" toAttribute:@"pts"];  

    [[RKObjectManager sharedManager].mappingProvider addObjectMapping:leaderboardMapping];

    RKObjectRouter *router = [RKObjectManager sharedManager].router;

    // Define a default resource path for all unspecified HTTP verbs  
    [router routeClass:[Leaderboard class] toResourcePath:leaderboardResourcePath];  
}

UPDATE

I found out that the problem is with the Geo object in the mappings. The geo object consists of three fields each of which also need to be mapped. Here is the mapping for the Geo object:

+ (void)setMappings
{
    //Standings mapping
    RKObjectMapping* geoMapping = [RKObjectMapping mappingForClass:[Geo class]];
    [geoMapping mapKeyPath:@"lat" toAttribute:@"lat"];
    [geoMapping mapKeyPath:@"lng" toAttribute:@"lng"];
    [geoMapping mapKeyPath:@"place" toAttribute:@"place"];

    [[RKObjectManager sharedManager].mappingProvider addObjectMapping:geoMapping];
    [[RKObjectManager sharedManager].mappingProvider setMapping:geoMapping forKeyPath:@"geo"];   
}

+ (void)initialize{
    [super initialize];
    if ([self class] == [Geo class]) {
        [self setMappings];
    } 
}

This causes the didLoadObjects to correctly pass back the objects but the Geo object of the Leaderboard object still comes back null. Thoughts?

  • 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-06-12T11:38:20+00:00Added an answer on June 12, 2026 at 11:38 am

    RESOLVED

    The issue lied with the mapping for the Geo object. If the object that restkit returns contains objects within it, you need to provide mappings for those objects as well. Here is the working code:

    + (void)setMappings
    {
        RKObjectMapping* leaderboardMapping = [RKObjectMapping mappingForClass:[Leaderboard class]];
        [leaderboardMapping mapAttributes:@"uname", @"week", @"year",  @"pts", nil];
    
        // Define the relationship mapping
        [leaderboardMapping mapKeyPath:@"geo" toRelationship:@"geo" withMapping:[Geo getMapping]];
    
        [[RKObjectManager sharedManager].mappingProvider addObjectMapping:leaderboardMapping];
    }
    

    Here is the geo object:

    +(RKObjectMapping*) getMapping{
        RKObjectMapping* geoMapping = [RKObjectMapping mappingForClass:[Geo class]];
        [geoMapping mapAttributes:@"lat", @"lng", @"place", nil];
        return geoMapping; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to get data back from an ajax call, and was using
i'm using an array of json objects back from a search webservice to feed
I am trying to get data back from a PHP file assigned with GET
I am trying to use a jQuery selector on data I get back from
I am trying to get a piece of data back using jQuery ajax via
I'm trying to get a json string back from my controller, that is prefill-values
According to my previous post I am trying to get back some information from
I am trying to handle an array coming back from an ajax call. My
I'm trying to get back 2 unique images form an array. Right now I'm
I'm trying to get an array that contains information from three tables. The result

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.