问题
I want to set RKObjectManager's delegate to nil. But I can't find delegate property.
My request is:
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"getData"
objectMapping:[[RKObjectManager sharedManager].mappingProvider
objectMappingForKeyPath:@"clips"] delegate:self];
UPDATE: There is a crash in my app. I go to "Clips" and in the viewDidLoad send loadObjectsAtResourcePath. If I rapidly leave this screen I get crash at [RKResponse connection:didReceiveData:].
回答1:
The crash is caused by your 'delegate' object being dealloc'd. There is a simple solution to your problem - just cancel all pending request eg. in your viewDidUnload (or dealloc, it depends on your implementation) method.
- (void)viewDidUnload
{
...
[[[[RKObjectManager sharedManager] client] requestQueue] cancelRequestsWithDelegate:self];
...
}
来源:https://stackoverflow.com/questions/8574775/how-do-i-set-rkobjectmanagers-delegate-to-nil