Question

I'm using the code below to post a managedObject. From the server, I'm not getting anything back, except 200, so there is no mapping for response object.

[self.objectManager postObject:invitation path:@"/path" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
        NSLog(@"success");
    } failure:^(RKObjectRequestOperation *operation, NSError *error) {
        NSLog(@"Failure");
    }]; 

Is there a dummy format I can use for RKResponseDescriptor ?

RKResponseDescriptor *responseDescriptor = nil;  //causes a crash
Was it helpful?

Solution

There is no 'dummy' RKResponseDescriptor instance, you must explicitly define what you want RestKit to do with the response data.

Your response descriptor can be partial, so it just maps one field to prove things are working.

Or, you could use a dynamic mapping to read the keys in the incoming data and create a mapping to NSMutableDictionary which includes all of the keys.

Both of these things are only really useful for testing, but may assist you.

If the response actually has no body data and you just want to monitor for success then you can either use AFNetworking instead, or create the response descriptor with a mapping to NSMutableDictionary and with no keys. RestKit should pick that up and it should act as a 'dummy' for your purposes. It will create a dictionary instance that is never used, but you can just ignore that.


RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];

RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:mapping
                                                                                        method:RKRequestMethodPOST
                                                                                   pathPattern:@"/path"
                                                                                       keyPath:nil
                                                                                   statusCodes:[self statusCodeSuccess]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top