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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:48:24+00:00 2026-06-02T16:48:24+00:00

I am using RestKit release/0.10.0 branch for my application. I’m using CoreData and RestKit’s

  • 0

I am using RestKit release/0.10.0 branch for my application. I’m using CoreData and RestKit’s object mapping feature to load/synchronize data. The XML data I am loading looks as follows (simplified):

<iphoneSync>
<time>12-04-03 16:47</time>
<pages>
    <page id="177">
        <title>
            Foo
        </title>
        <meta>
            <tags>
                <tag type="undef" id="16">Lorem</tag>
                <tag type="undef" id="20">Ipsum</tag>
            </tags>
        </meta>         
    </page>
    <page id="580">
        <title>
            Bar
        </title>
        <meta>
            <tags>
                <tag type="undef" id="16">Lorem</tag>
                <tag type="undef" id="20">Ipsum</tag>
                <tag type="" id="46">Abc</tag>
                <tag type="symptom" id="47">Cde</tag>
            </tags>
        </meta>
    </page>
</pages>

The domain classes Page and Tag look as follows:

@interface Page : NSManagedObject
@property (nonatomic, strong) NSNumber * id;
@property (nonatomic, strong) NSString * title;
@property (nonatomic, strong) NSSet *tags;
@end

@interface Tag : NSManagedObject
@property (nonatomic, strong) NSNumber * id;
@property (nonatomic, strong) NSString * name;
@property (nonatomic, strong) NSString * type;
@property (nonatomic, strong) NSSet *pages;
@end

The Page entity has many tags and a Tag can belong to multiple pages. So I have set the relationship from both sides to be To-many. The delete rule from Page to tags is cascade. From Tag to Pages it’s nullify.

CoreData properties

The mapping setup:

//Tag mapping
RKManagedObjectMapping* tagMapping = [RKManagedObjectMapping mappingForClass:[Tag class] inManagedObjectStore:[RKManagedObjectStore defaultObjectStore]];
tagMapping.setDefaultValueForMissingAttributes = YES;
tagMapping.primaryKeyAttribute = @"id";
[tagMapping mapKeyPathsToAttributes:@"type",@"type",@"text",@"name",@"id",@"id", nil];

//Page mapping
RKManagedObjectMapping* pageMapping = [RKManagedObjectMapping mappingForClass:[Page class] inManagedObjectStore:[RKManagedObjectStore defaultObjectStore]];    
pageMapping.primaryKeyAttribute = @"id";
[pageMapping mapKeyPathsToAttributes:@"id",@"id",@"title",@"title",nil];
[pageMapping mapKeyPath:@"meta.tags.tag" toRelationship:@"tags"  withMapping:tagMapping];
pageMapping.setNilForMissingRelationships = YES;
pageMapping.setDefaultValueForMissingAttributes = YES;

//Root mapping
RKObjectMapping* rootMapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];
[rootMapping mapKeyPath:@"iphoneSync.pages.page" toRelationship:@"pages" withMapping:pageMapping];

//RKObjectManager
RKManagedObjectStore* mainManagedObjectStore = [RKManagedObjectStore objectStoreWithStoreFilename:OBJECT_STORE_FILE];
RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:baseURL];
[RKObjectManager setSharedManager:objectManager];
objectManager.acceptMIMEType = RKMIMETypeXML;
objectManager.serializationMIMEType = RKMIMETypeXML;
objectManager.objectStore = mainManagedObjectStore;
objectManager.objectStore.cacheStrategy = [RKInMemoryManagedObjectCache new];
objectManager.client.cachePolicy = RKRequestCachePolicyNone;

[objectManager.mappingProvider addObjectMapping:rootMapping];    
[objectManager.mappingProvider addObjectMapping:pageMapping];
[objectManager.mappingProvider addObjectMapping:tagMapping];

Then I load it like this:

[objectManager loadObjectsAtResourcePath:@"/" usingBlock:^(RKObjectLoader* loader) {
    loader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[NSMutableDictionary class]];
}];

The objects are loaded and mapped properly, but the tags with ID 16 and ID 20 are stored twice in the database (one for each page entity). But I want them to be distinct such that tags with the same ID are only stored once. What am I doing wrong?

  • 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-02T16:48:25+00:00Added an answer on June 2, 2026 at 4:48 pm

    This issue has been resolved. It was a bug in RestKit. See https://github.com/RestKit/RestKit/issues/661
    Clone the latest version of the development branch to have a working version.

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

Sidebar

Related Questions

i am using coredata and restkit to map data. here is the json response
I'm using RestKit to develop a RESTful application. I have a wrapper object that
I'm using RestKit to load a gzipped JSON with RKRequest: RKRequest* request = [[RKClient
I'm using RestKit to grab objects from my RoR service and using CoreData to
I am using restkit and I have problems parsing an xml: Unable to find
I am using the great RestKit Framework for an iPhone Application. I have got
I was using https://github.com/RestKit/RestKit/wiki/Using-Multiple-Base-URLs-%28and-Multiple-Object-Managers%29 as a guide. I know it's possible to create multiple
I'm developing an app in IOS using RestKit . Data is retrieved successfully but
I want to use RestKit to parse XML data from our servers. Downloading and
I am having trouble mapping a JSON response to objects using RestKit and Objective-C.

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.