我的代码中有这个:
- (void)loadPanoramaForLocation:(CLLocation *)location
{
dispatch_group_t group = dispatch_group_create();
...
dispatch_group_enter(group);
[self getImageForPanorama:model level:level face:PLCubeFaceOrientationFront completion:^(PLImage * image) {
if (image) {
[cubicPanorama setTexture:[PLTexture textureWithImage:image] face: PLCubeFaceOrientationFront];
dispatch_group_leave(group);
}
}];
...
dispatch_group_enter(group);
[self getImageForPanorama:model level:level face:PLCubeFaceOrientationBack completion:^(PLImage * image) {
if (image) {
[cubicPanorama setTexture:[PLTexture textureWithImage:image] face: PLCubeFaceOrientationBack];
dispatch_group_leave(group);
}
}];
...
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
dispatch_release(group);
NSObject<PLIPanorama> *panorama = cubicPanorama;
[plView setPanorama:panorama];
});
}
我没有在这段代码中使用 ARC,我想知道,这里使用 dispatch_release
的方法是否正确?我应该把它放在哪里?放在dispatch_group_notify
里可以吗?谢谢
最佳答案
您可以在 -loadPanoramaForLocation:
中将其作为最后一件事发布。 dispatch_group_notify()
被记录为保留它直到通知 block 运行完成。所以,一旦你调用了它,就没有必要保留你的强引用。
关于ios - 我应该在哪里释放组队列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25131322/