Note that there are some explanatory texts on larger screens.

plurals
  1. PORestKit: Sending particular JSON, Please help, i've tried everything I can think of
    primarykey
    data
    text
    <p>all ...</p> <p>I've spent all weekend on this and the problem still happens. I don't know what else to do and any help would be very much appreciated. I'm trying to send JSON like this:</p> <pre><code> { "proof": { "name":"fluff", "media_type":"Photo", "description":"This is a description" }, "auth_token":"mphxNcEGJMJyU7iPmaLw" } </code></pre> <p>I keep getting the following exception from RestKit:</p> <p>2012-07-23 10:29:17.001 restkittest[8389:707] <em>*</em> Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ valueForUndefinedKey:]: this class is not key value coding-compliant for the key auth_token.'</p> <p>I suspect it's because the auth_token isn't a part of the object (proof) i'm passing, but I don't know how to pass the auth_token along with the proof since postObject only takes one object to post.</p> <p>... and this is my code to try to do it:</p> <pre><code>@implementation proof @synthesize name; @synthesize description; @synthesize media_type; @synthesize duration; @synthesize frequency_id; @end @implementation auth_token @synthesize auth_token; @end - (BOOL)createProof:(proof *)proof { BOOL ret = NO; [self.objectManager postObject:proof usingBlock:^(RKObjectLoader *loader) { loader.delegate = self; RKObjectMapping *proofMappingAccept = [RKObjectMapping mappingForClass:[proof class]]; [proofMappingAccept mapKeyPath:@"name" toAttribute:@"name"]; [proofMappingAccept mapKeyPath:@"description" toAttribute:@"description"]; [proofMappingAccept mapKeyPath:@"media_type" toAttribute:@"media_type"]; [proofMappingAccept mapKeyPath:@"duration" toAttribute:@"duration"]; RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]]; [mapping mapKeyPath:@"auth_token" toAttribute:@"auth_token"]; [mapping mapKeyPath:@"proof" toRelationship:@"proof" withMapping:proofMappingAccept]; loader.serializationMapping = [mapping inverseMapping]; loader.objectMapping = mapping; }]; return ret; } </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.
    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