을 필요로있을 때 dispatch_async 조치를 취소하지 나는 내가해야 할 것은 내가이의 ViewController를 팝업 할 때 getItems
을 중지하는 것입니다 viewDidLoad
더 이상
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
items = [[DataFetcher sharedInstance] getItems handler:^(NSArray *currentItems){
if (currentItems.count % 30 == 0) { //don't wait for all the items to be ready show by chunks of 30
items = currentItems;
[tableView reloadData];
}
items = currentItems;
}];//Pretty complex call that takes some time to finish there is WebService calls, data parsing, storing some results ...
dispatch_async(dispatch_get_main_queue(), ^{
[tableView reloadData];
});
});
에서 다음을 수행하는 UIViewController
있습니다. 그것은 무의미하며 CPU 시간과 에너지를 필요로합니다 (이 호출은 경우에 따라 최대 1 분이 소요될 수 있습니다).
내가 정확히 viewWillDisappear
에서 이렇게해야한다고 가정합니다.
'self'가 소유 한 작업에서 'self'를 강력하게 캡처하면 유지주기가 만들어집니다. 이 예제는 취소 사례의 종속성을 지우지 만 성공적인 완료 사례의 종속성은 지 웁니다. – ipmcc
그래, 내가 언급 했어야 했어. 그것을 지적 주셔서 감사합니다. [이 질문에 대한 자세한 내용은] (http://stackoverflow.com/q/8113268/1445366)을 참조하십시오. –