0
votes

I am saving 4 different tokens on Server using Restkit Coredata. using response descriptor.

RKResponseDescriptor *tokenDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:instagramToken method:RKRequestMethodGET pathPattern:@"register/token" keyPath:@"data" statusCodes:statusCodes];

// And I'm calling it this way.

 [[RKObjectManager sharedManager] getObjectsAtPath:@"register/token" parameters:params success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {


    } failure:^(RKObjectRequestOperation *operation, NSError *error) {

    }];

it is storing very well and I can access it in coredata as well. but the problem is, If I save 1 token on server and map the response all good no issue in that. But when I save other token on Server the new response get mapped in coredata and over-right the old response. I want to keep all the responses in coredata.

Please help on this.

1

1 Answers

0
votes

The server needs to return a unique identity for each token so you know which is which. You need an attribute in your model to store that and you need to add that to the mapping and set it as the mapping identification attribute. Finally you need to connect your RK managed object store with an object cache so that it can search for duplicates to update (instead of always creating new instances).