如何将 RKObjectManager 的委托设置为 nil? [英] How do I set RKObjectManager's delegate to nil?
问题描述
我想将 RKObjectManager 的委托设置为 nil.但是我找不到委托属性.
I want to set RKObjectManager's delegate to nil. But I can't find delegate property.
我的要求是:
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"getData"
objectMapping:[[RKObjectManager sharedManager].mappingProvider
objectMappingForKeyPath:@"clips"] delegate:self];
更新:我的应用程序崩溃了.我转到剪辑"并在 viewDidLoad 中发送 loadObjectsAtResourcePath.如果我迅速离开这个屏幕,我会在 [RKResponse connection:didReceiveData:] 处崩溃.
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:].
推荐答案
崩溃是由于您的委托"对象被释放.您的问题有一个简单的解决方案 - 只需取消所有待处理的请求,例如.在您的 viewDidUnload(或 dealloc,这取决于您的实现)方法中.
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];
...
}
这篇关于如何将 RKObjectManager 的委托设置为 nil?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!