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 8704601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:08:55+00:00 2026-06-13T03:08:55+00:00

I need to map a nested array with RestKit and I’ve almost got it

  • 0

I need to map a nested array with RestKit and I’ve almost got it (I think).

The JSON I need to map, looks like this

[
    {
        _id: "5058670183970a0002000450",
        app_store_url: "http://itunes.apple.com/app/culturonda-alto-adige-sudtirol/id534467629",
        comments: [
            {
                _id: "5058670783970a0002000456",
            },
            {
                _id: "50588d7f83970a000200065c",
            }
        ]
    }
]

My controllers to store the info looks like this:

#import <Foundation/Foundation.h>
#import "CommentData.h"

@interface DesignData : NSObject
    @property (retain, nonatomic) NSString *designId;
    @property (retain, nonatomic) NSSet *commentsRelationship;
@end

And:

#import <Foundation/Foundation.h>

@interface CommentData : NSObject
    @property (retain, nonatomic) NSString *commentId;
@end

My mapping looks like this:

RKObjectManager *objectManager = [RKObjectManager sharedManager];

RKObjectMapping *commentsMapping = [RKObjectMapping mappingForClass:[CommentData class]];
[commentsMapping mapKeyPathsToAttributes:@"_id", @"commentId", nil];

RKObjectMapping *designMapping = [RKObjectMapping mappingForClass:[DesignData class] ];
[designMapping mapKeyPathsToAttributes:@"_id", @"designId", nil];

[designMapping mapKeyPath:@"comments" toRelationship:@"commentsRelationship" withMapping:commentsMapping];

[objectManager.mappingProvider setMapping:designMapping forKeyPath:@""];

Comments gets into an array, but it doesn’t get stored in the comments controller. If I display the comments in the objecloader callback like this:

DesignData *designData = [objects objectAtIndex:0];
NSLog(@"Loaded %@ ", designData.commentsRelationship);

it gives me:

2012-10-20 22:37:55.258 RestKitTest5[4144:c07] Loaded {(
                                                        <CommentData: 0x8689730>,
                                                        <CommentData: 0x868bed0>,
                                                        <CommentData: 0x868bfe0>,
                                                        <CommentData: 0x868bf50>
                                                        )}

Which is a start. But I can’t do:

DesignData *designData = [objects objectAtIndex:0];
NSLog(@"Loaded %@ ", designData.commentsRelationship.commentId);

So how do I store the whole thing as an array?

  • 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-13T03:08:56+00:00Added an answer on June 13, 2026 at 3:08 am

    I was already doing it right, I was just being stupid in the end.

    I got the array and the objects in the array was of the right kind (CommentData), so all I had to do was to loop through the array and from there I could work with each object separately.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I map the nested json below with RestKit RKObjectMapping? I only need
Need a map reduce function by mongo in php This my mongo structure [_id]
I have nested routes like this : map.resources :foo do |foo| foo.resources :bar do
I need to map a single fixed sized array array to multiple properties. For
I have a C++ key/value table that looks like this: class kvBucket { ...
I have a json nested object, similar to this . In my case, I
I have a set of data(key value pair) which I need map to json,
In a simple webapp I need to map URLs to filenames or filepaths. This
In php, I often need to map a variable using an array ... but
I need to map 100 tabels for fluent nhibernate. I can do this by

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.