The question actually has some misconceptions about when RestKit performs refetching. Under the circumstances described in the question, RestKit actually does return an instance of RKRefetchingMappingResult
in the success
block. Calling any of the accessors on that object (such as array
or firstObject
) actually does perform the refetching. The mistake was that I was never invoking any of these methods on the RKMappingResult
.
My assumption was that, since the object I was sending in the PUT request would become the operation's targetObject
, the object would be updated in-place by RestKit. This is why I never felt the need to do anything with the RKMappingResult
. The assumption isn't technically wrong, but by accessing the object directly once the mapping was complete instead of using the RKMappingResult
, I was skipping the refetching step.
I've proposed a change in this behaviour in an issue I've filed with the RestKit folks, to make refetching automatic in certain circumstances.
To summarize:
When making a request using RKManagedObjectRequestOperation
(whether you specify that manually or RestKit selects this class for you), always make sure you exercise the RKMappingResult
to ensure that the results are re-fetched from the correct NSManagedObjectContext
.