Note that there are some explanatory texts on larger screens.

plurals
  1. PORestKit: per-request object mapping when using [[RKClient sharedClient] post: usingBlock:]
    primarykey
    data
    text
    <p>I need to POST a video to a server in the background. Until now i've been using this sort of pattern when POSTing:</p> <pre><code>- (BOOL)loginUser:(user *)user { BOOL ret = NO; AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [appDelegate.waitView startWithMessage:@"Signing in ..."]; [self.objectManager postObject:user usingBlock:^(RKObjectLoader *loader) { loader.delegate = self; loader.targetObject = nil; loader.objectMapping = [RKObjectMapping mappingForClass:[user class] usingBlock:^(RKObjectMapping *mapping) { [mapping mapKeyPath:@"id" toAttribute:@"ID"]; [mapping mapKeyPath:@"last_name" toAttribute:@"last_name"]; [mapping mapKeyPath:@"first_name" toAttribute:@"first_name"]; [mapping mapKeyPath:@"middle_name" toAttribute:@"middle_name"]; [mapping mapKeyPath:@"email" toAttribute:@"email"]; [mapping mapKeyPath:@"password" toAttribute:@"password"]; [mapping mapKeyPath:@"authentication_token" toAttribute:@"authentication_token"]; }]; loader.serializationMapping = [loader.objectMapping inverseMapping]; loader.serializationMapping.rootKeyPath = NSStringFromClass([user class]); }]; return ret; } </code></pre> <p>... but this pattern doesn't seem to let me access any RKRequest object on which to set the backgroundPolicy. So, i've looked at using RKClient like so:</p> <pre><code>- (BOOL)postBigMediaFile:(NSString *)pathToBigFile { BOOL ret = NO; NSString *resourcePath = @"/bigFile"; [[RKClient sharedClient] post:resourcePath usingBlock:^(RKRequest *request) { request.backgroundPolicy = RKRequestBackgroundPolicyContinue; // how do I set up the object mapping? }]; return ret; } </code></pre> <p>... but the RKRequest object doesn't seem to have a way of accessing an RKObjectLoader for which to setup the mapping on. How do I post data in the background using object mapping?</p>
    singulars
    1. This table or related slice is empty.
    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