使用RestKit,使用block加载对象,何时以及如何取消请求? [英] Using RestKit, use block to load object, when and how to cancel the request?
本文介绍了使用RestKit,使用block加载对象,何时以及如何取消请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"app/site_pattern" usingBlock:^(RKObjectLoader* loader) {
[loader setObjectMapping:clientMappring];
loader.delegate = self;
shopLoader = loader;
}];
上面,我使用块函数在应用程序中加载一些数据,但是当我弹出该ViewController时,我不知道何时以及如何取消此请求.
Above, I use the block function to load some data in my app, but when I pop this viewcontroller, I don't know when and how to cancel this request .
有什么主意吗?
- (void)showSelectShop
{
SelectShopViewController * selectShopViewController = [[SelectShopViewController alloc] initWithNibName:@"SelectShopViewController" bundle:nil];
[self.navigationController pushViewController:selectShopViewController animated:YES];
}
更多:
我尝试在viewDidUnload中取消它
I try to cancel it in the viewDidUnload
- (void)viewDidUnload
{
[super viewDidUnload];
[shopLoader cancel];
}
但是没有用.我仍然遇到错误.
But it didn't work. I still getting error.
推荐答案
我通过添加
- (void)viewWillDisappear:(BOOL)animated
{
[shopLoader cancel];
shopLoader.delegate = nil;
shopLoader = nil;
}
我仍然想知道是否不想在viewWillDisappear中取消此请求,这些行应写入哪个函数?
I still want to know if I don't want to cancel this request in viewWillDisappear, which function do those lines should be written in?
这篇关于使用RestKit,使用block加载对象,何时以及如何取消请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文