Open inksword opened 8 years ago
+1 Just encountered this myself also. There is no line of code in RKObjectManager
that calls managedObjectRequestOperationWithRequest(_:managedObjectContext:success:failure:)
, so subclassing to change the behaviour of managed object request operations doesn’t work as described in the docs.
The workaround for now is to instead override appropriateObjectRequestOperationWithObject(_:method:path:parameters:)
and perform the customisation if the request op returned by super is of type RKManagedObjectRequestOperation
:
override func appropriateObjectRequestOperationWithObject(object: AnyObject!, method: RKRequestMethod, path: String!, parameters: [NSObject : AnyObject]!) -> AnyObject! {
let requestOp = super.appropriateObjectRequestOperationWithObject(object, method: method, path: path, parameters: parameters)
if let managedObjectRequestOp = requestOp as? RKManagedObjectRequestOperation {
// Customise the managed object request op...
}
return requestOp
}
When I am trying to subclass RKObjectManager, I found the following comments:
However, when I overwrite
managedObjectRequestOperationWithRequest:managedObjectContext:success:failure
, the method is never called, because its never called byappropriateObjectRequestOperationWithObject:method:path:parameters:
in RKObjectManager.