How do I set RKObjectManager's delegate to nil?

余生颓废 提交于 2019-12-23 01:04:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!