탐색 모음에서 뒤로 단추를 클릭 할 때 비동기 작업을 중지하는 방법을 알고 싶습니다.이 코드를 수행했지만 작동하지 않습니다 ... dispatch_group_t imageQueue = dispatch_group_create(); viewdisappear에서 ios에서 dispatch_queue를 중지하는 방법은 무엇입니까?
dispatch_group_async(imageQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
imagedata=[[NSMutableArray alloc]init];
for (int i=0; i<[imageURL count]; i++)
{
NSLog(@"clicked ");
[imagedata addObject:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[imageURL objectAtIndex:i]]]]];
[[NSNotificationCenter defaultCenter] postNotificationName:@"Avatardownloaded" object:imagedata userInfo:nil];
}
});
....
-(void)viewDidDisappear:(BOOL)animated
{
dispatch_suspend(imageQueue);
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"Avatardownloaded" object:nil];
[[NSNotificationCenter defaultCenter]release];
[avatarimages release];
[imagedata release];
[imageURL release];
}
내가 그것을 실행이 중지 나던 스레드를 중단하더라도 background.Anyone에서 실행의 keepon pls는 저
이 링크를 확인하십시오. 도움이 될 수도 있습니다. http://stackoverflow.com/questions/6737044/suspending-gcd-query-problem/6737719#6737719 – freshking
또한 기본 알림 센터를 해제하려고 시도하지 마십시오. –