0

I use an RKObjectManager to load objects from a remote resource, and, use a tableView to display the fetched objects. When my tableView model is deallocated I cancel all current requests with

[self.objectManager cancelAllObjectRequestOperationsWithMethod:RKRequestMethodGET matchingPathPattern:self.resourcePath];

When the user reloads the view, a new model is created - Instead of creating the objectManager from scratch, I fetch the same one (I store the objectManager instance elsewhere). I'm trying to use a single object manager across the app for the same service/site - not sure if we can use multiple object managers against the same persistent object store? However, now all requests to the resource path fails with the following error.

restkit.network:RKObjectRequestOperation.m:569 Object request failed: Underlying HTTP request operation failed with error: Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)"

It looks like once I cancel against a resource path on an objectManager, I can't reload that resource via a fresh request at a later point in time. What would the best practice be to cancel current requests and reload later? In the earlier delegates version of restkit, my app would crash if I didn't remove my model/view as delegate from the object manager. I'm thinking I should still cancel my requests to avoid such issues even with the new blocks way of operation? Pointers/advice much appreciated. Thanks

Regards

George M.P.

georgemp
  • 716
  • 10
  • 21

1 Answers1

0

not sure if we can use multiple object managers against the same persistent object store?

No problem with that.

When the user reloads the view, a new model is created - Instead of creating the objectManager from scratch, I fetch the same one...

If you create a new model (I guess you mean managed object store?) you should probably create a new object manager to go with it. In theory you can give the old object manager the new store but there is (or could be) a lot of internal caching that could be invalidated.

Cancelling and then reloading later should be fine, the question is what you're doing with the object store in between...

Wain
  • 118,658
  • 15
  • 128
  • 151