Using RestKit, use the block to load the object, when and how to cancel the request?

[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"app/site_pattern" usingBlock:^(RKObjectLoader* loader) {
    [loader setObjectMapping:clientMappring];
    loader.delegate = self;
    shopLoader = loader;
}];

Above, I use the block function to load some data in my application, but when I exit this view controller, I don't know when and how to cancel this request.

Any idea?

- (void)showSelectShop
{

    SelectShopViewController * selectShopViewController = [[SelectShopViewController alloc] initWithNibName:@"SelectShopViewController" bundle:nil];
    [self.navigationController pushViewController:selectShopViewController animated:YES];
}

More details:

I am trying to undo it in viewDidUnload

- (void)viewDidUnload
{
    [super viewDidUnload];
    [shopLoader cancel];
}

But that did not work. I am still getting the error.

+3
source share
1 answer

I solved this by adding

- (void)viewWillDisappear:(BOOL)animated
{
    [shopLoader cancel];
    shopLoader.delegate = nil;
    shopLoader = nil;
}

I still want to know if I want to cancel this request in viewWillDisappear, in which function should these lines be written?

+2
source

All Articles