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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:46:21+00:00 2026-06-08T00:46:21+00:00

I am currently developing an iOS Messenger application and I would like to talk

  • 0

I am currently developing an iOS Messenger application and I would like to talk about these two classes relationship: MessengerConversation and MessengerMessage.

Supposing that I already have a local MessengerConversation instance which can have many MessengerMessage instances related into its messages relationship property, I would like to request and mapping the following JSON payload:

Request: GET /conversations/:conversationID/msgs
Response:

{
  "messages": [
    {
      ...
      "messageid": n,
      "content": "..."
      ...
    },
    ...
  ]
}

As the response JSON payload didn’t indicate which conversation the delivered messages are from. I used the following approach to fix this issue into my MessengerManager class (Responsible for interacting with the shared RKObjectManager instance):

- (void)objectLoader:(RKObjectLoader *)objectLoader willMapData:(inout id *)mappableData {
    //
    // GETs Resource Paths.
    if ([objectLoader method] == RKRequestMethodGET) {

        if ([pathMatcherConversationsMessagesGET matchesPath:objectLoader.resourcePath tokenizeQueryStrings:NO parsedArguments:Nil]) {
            //
            // Get requested conversationID from the following resource path Pattern:
            // kMessengerManagerResourcePathMessages: /conversations/:conversationID/msgs
            NSNumber *currentConversationID = Nil;
            NSDictionary *arguments = Nil;

            BOOL isMatchingPattern = [pathMatcherConversationsMessagesGET matchesPattern:kMessengerManagerResourcePathConversationsMessagesGET 
                                                                    tokenizeQueryStrings:YES 
                                                                         parsedArguments:&arguments];

            if (isMatchingPattern) {
                currentConversationID = [arguments objectForKey:@"conversationID"];
                //
                // Get the original returned array of messages:
                NSArray *origMessagesArray = [*mappableData valueForKeyPath:@"messages"];
                NSMutableArray *reformattedData = [NSMutableArray arrayWithCapacity:[origMessagesArray count]];
                //
                // Create copies of objects adding the already knew reference.
                for (NSDictionary *origMessagesArrayObject in origMessagesArray) {
                    NSMutableDictionary *newMessagesArrayObject = [origMessagesArrayObject mutableCopy];
                    [newMessagesArrayObject setObject:currentConversationID forKey:@"conversationid"];
                    [reformattedData addObject:newMessagesArrayObject];
                }
                //
                // Replace the new objects instead of the response objects
                [*mappableData setObject:reformattedData forKey:@"messages"];
            }
        }
    }    
}

And so everything worked properly. That is, all loaded MessengerMessages from the specified MessengerConversation (into the RKObjectLoader resource path) are being inserted into the wanted relationship.

Now comes the real problem, as I am working with my MessengerManager class which adopts the RKObjectLoaderProtocol, I could implement the objectLoader:willMapData: method. But as my View classes are using the RKFetchedResultsTableController and every table controller instance is also its RKObjectLoader delegate, I don’t know which would be the best practice to enable a RKFetchedResultsTableController instance to update a received JSON payload before the mapping operation.

Shall I subclass it?

And are there better ways to map received objects into a pre-defined object specified by a RKObjectLoader resource path (e.g: GET /conversations/2/msg where all resulted messages should be mapped inside the defined MessengerConversation object with its primary key value equal to 2)?

Best regards,
Piva

  • 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-08T00:46:23+00:00Added an answer on June 8, 2026 at 12:46 am

    You don’t need this method. When you launch the RKObjectLoader, set your Conversation object as the targetObject and make the mapping relative to this object. For example:

    RKManagedObjectMapping* cMapping = [RKManagedObjectMapping mappingForClass: [MessengerConversation class]];
    RKManagedObjectMapping* mMapping = [RKManagedObjectMapping mappingForClass: [MessengerMessage class]];
    
    //Configure mappings
    
    [cMapping mapKeyPath: @"messages" toRelationship: @"messages" withObjectMapping: mMapping];
    
    [mappingProvider setMapping cMapping forKeyPath: @""];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a web application based on jQuery Mobile. I would like to
My team and I are currently developing an application for both Android and iOS
I am currently developing an application which is using the Dropbox iOS SDK version
I've been having some fun with Flash developing IOS apps. I currently have two
I'm developing an iOS application which (like any other) requires a certain amount of
I just started iOS development am currently developing an application that just reads data
I am currently developing an iOS application that needs a backend to pull data
I'm currently developing an iOS application (iPad and iPhone) that uses OpenGL ES 1.0
I am currently in the process of developing two iOS applications which heavily rely
Currently developing an application using the newest version of symfony, obtained through PEAR. This

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.