Question

I am trying to use the delete orphaned objects feature of RestKit 0.20+ but it looks like it only supports GET request.

I am using POST requests instead and I do not have access to the server configuration to switch GET support on. And as a side note, I probably couldn't use GET anyway as the objects posted are sometimes bigger than 1024 bytes.

Is there any way to turn it on for POST requests as well?

If not, is there any way to add some custom code to do a check on the returned response and eventually delete objects from Core Data before RestKit serializes them to the store? That way I could just add a custom check on a custom cache key and clear the data accordingly.

Was it helpful?

Solution

Correct, it is only enabled for GET requests. The only way to turn it on would be to edit the RestKit code. Generally it would not be expected to purge orphans in response to a POST because POST should be used for creating items and the response would contain only that item.

You would need to do some subclassing and handling of various operations to add code into the end of the mapping process before the context is saved.

You could consider observing NSManagedObjectContextWillSaveNotification, but you should be aware that RestKit will be processing changes on a background thread and that is were the notification will be processed (this should help you, but you should be aware of it).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top