Note that there are some explanatory texts on larger screens.

plurals
  1. PORestKit pathpatterns including IDs
    primarykey
    data
    text
    <p>So the problem is that when I'm trying to load entity from <a href="http://dealer-app.net/api/cars/2/features.json?auth_token=Mg7Kd7pb1CG9dBZmx4Q9" rel="nofollow">here</a> I'm not getting things to work. My Pathpatterns seems to be wrong. Here's my Mapping and Descriptor:</p> <pre><code>RKEntityMapping *statsMapping = [RKEntityMapping mappingForEntityForName:@"Stat" inManagedObjectStore:managedObjectStore]; [statsMapping addAttributeMappingsFromDictionary:@{ @"sort_id" : @"sortID", @"id" : @"statID", @"deleted" : @"deletedFlag", @"created_at": @"createdAt", @"updated_at": @"updatedAt" }]; statsMapping.identificationAttributes = @[ @"statID" ]; [statsMapping addAttributeMappingsFromArray:@[ @"title"]]; RKEntityMapping *featuresMapping = [RKEntityMapping mappingForEntityForName:@"Feature" inManagedObjectStore:managedObjectStore]; [featuresMapping addAttributeMappingsFromDictionary:@{ @"sort_id" : @"sortID", @"id" : @"featureID", @"deleted" : @"deletedFlag", @"created_at": @"createdAt", @"updated_at": @"updatedAt", }]; featuresMapping.identificationAttributes = @[ @"featureID" ]; [featuresMapping addAttributeMappingsFromArray:@[ @"title", @"value"]]; [statsMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"features" toKeyPath:@"features" withMapping:featuresMapping]]; RKResponseDescriptor *statsDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:statsMapping pathPattern: @"/api/cars/:carID/features.json" keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; [objectManager addResponseDescriptorsFromArray:@[newsDescriptor, catalogDescriptor, statsDescriptor]]; </code></pre> <p>So when I use pathPattern:nil it works, but if no answer is returned by url it just tries to put another responsedescriptor to the response and gives me random data :) </p> <p>The question is, if I have the car ID in the middle of the pattern, how should I declare it?</p> <p>Thank you!</p> <p>Edit1: This is how I do request:</p> <pre><code> - (void)getStats:(NSNumber *)carID { [[RKObjectManager sharedManager] getObjectsAtPath:[NSString stringWithFormat:@"api/cars/%@/features.json", carID] parameters:@{@"auth_token" : [Constants authToken]} success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { RKLogInfo(@"Load complete: Stats loaded"); } failure:^(RKObjectRequestOperation *operation, NSError *error) { RKLogError(@"Load failed with error: %@", error); [self showError:error withDelay:3]; }]; } </code></pre>
    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.
 

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