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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:02:50+00:00 2026-06-16T03:02:50+00:00

I’m having an issue mapping posts from ADN into my database. Please keep in

  • 0

I’m having an issue mapping posts from ADN into my database.

Please keep in mind I am using MagicalRecord to automatically map the JSON to the NSManagedObjects I’ve setup.

The JSON can be seen here: http://web.archive.org/web/20170123035402/https://developers.app.net/reference/resources/post/, specifically the section with the entities.

My Core Data model has been setup with the following relationships:

Post <-> Entities <->> Links/Hashtags/Mentions

The relationships have been setup with the proper names so MagicalRecord should be able to map down the tree just fine. The Post object has a bunch of attributes. Its relationship to the Entities object is called “entities” and this is where it seems to fail because of the primary key (AFAIK from where it breaks in the code in MagicalRecord).

Due to the fact that Entities is basically just an object to hold the relationships to each entity type, I don’t have any attributes for the Entity object. Unfortunately it doesn’t seem to help setting an attribute with a random name for the Entity object.

Based on the above information, is there anything you would do differently to map the relationships and objects properly? Is it OK to have this empty Entities object that I just use for the relationships to each entity type, sort of how the ADN post has been setup with the “entities” dictionary.

  • 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-16T03:02:51+00:00Added an answer on June 16, 2026 at 3:02 am

    So the issue does lie a bit with MagicalRecord and myself for the way I had set up the NSManagedObjects and relationships.

    MagicalRecord uses a primary key to handle the relationships. If one hasn’t been set it uses one of the attributes. In my case the Entities NSManagedObject did not have any attributes because I am just using it to handle the relationships to each of the entity types.

    The code for this can be found in NSObject+MagicalDataImport.m:

    - (NSString *) MR_lookupKeyForRelationship:(NSRelationshipDescription *)relationshipInfo
    {
        NSEntityDescription *destinationEntity = [relationshipInfo destinationEntity];
        if (destinationEntity == nil) 
        {
            MRLog(@"Unable to find entity for type '%@'", [self valueForKey:kMagicalRecordImportRelationshipTypeKey]);
            return nil;
        }
    
        NSString *primaryKeyName = [relationshipInfo MR_primaryKey];
    
        NSAttributeDescription *primaryKeyAttribute = [[destinationEntity attributesByName] valueForKey:primaryKeyName];
        NSString *lookupKey = [[primaryKeyAttribute userInfo] valueForKey:kMagicalRecordImportAttributeKeyMapKey] ?: [primaryKeyAttribute name];
    
        return lookupKey;
    }
    

    Specifically [[destinationEntity attributesByName] valueForKey:primaryKeyName]; returning nil.

    At first I had tested with a attribute called “test”, but I am not sure what I had done that didn’t work, perhaps not done a good enough job clearing the cache. I tried again to clear the relationships so I didn’t have those to worry about and then I added an attributes “entities” on the Entities NSManagedObject and it all worked great!

    Sorry. Just adding the answers and comments in case anyone ever comes across this issue where they are using MagicalRecord and the NSManagedObject does not have any attributes.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I am currently running into a problem where an element is coming back from
I am using jsonparser to parse data and images obtained from json response. When
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.