Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So you've created the mapping for each NSManagedObject (and they work), but now you want to establish a relationship between "Category" and "Elements".</p> <p>The problem is that there isn't an information for the mapping of Elements in which Category each element belongs (the unique key is missing). So you need to add the <code>cat_id</code> to the Elements JSON to ensure that this keypath is available.</p> <pre><code>// Elements JSON [ { "cat_id": "1313", "art_id": "1", "node": { "author": "name" }, "small_url": 0 }, ... ] // Edit keypath in relationship mapping [elementsMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"cat_id" toKeyPath:@"category" withMapping:categoryMapping]]; </code></pre> <p>In addition you could use the following to methods to track if the mapping works. </p> <pre><code>1) -com.apple.CoreData.SQLDebug 1 // Add in "Arguments" Tab &gt; "Arguments Passed On Launch" 2) RKLogConfigureByName("RestKit/*", RKLogLevelTrace); // Add to AppDelegate` </code></pre> <h2>Edit</h2> <h3>Mapping</h3> <p>Did you update the entity <code>Elements</code> in your Data Model and your NSManagedObject with the given value? Seems like you didn't.</p> <pre><code>@interface Elements : NSManagedObject @property (nonatomic, retain) NSNumber * catId; @property (nonatomic, retain) NSNumber * artId; @property (nonatomic, retain) NSString * author; @property (nonatomic, retain) NSString * title; @property (nonatomic, retain) NSManagedObject *category; @end </code></pre> <h3>Routing</h3> <p>The path your using for your get request won't work because <code>@"/detailaddress/:catId"</code> isn't a valid path. You can on the one hand set the routing of the object manager in general or define a response description.</p> <pre><code> // Route for get operation [[RKObjectManager sharedManager].router.routeSet addRoute:[RKRoute routeWithClass:[Category class] pathPattern:@"/detailaddress/:catId" method:RKRequestMethodGET]]; // Response descriptor taken from the Core Data same application RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:categoryMapping pathPattern:@"/detailaddress/:catId" keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; [objectManager addResponseDescriptor:responseDescriptor]; // Use general path for get request [[RKObjectManager sharedManager] getObjectsAtPath:@"/detailaddress" ... </code></pre> <p>But please check if the mapping and data model is set like expected first.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload