当我尝试在swift中创建两个单独的调度组时,我的代码在第一个创建时崩溃了,但是当我注释掉其中任何一个时,代码运行正常。以下是我的两个调度组。我需要代码在不同的时间运行,所以我需要两个单独的组。也许我在错误地初始化这些?
dispatch_group_notify(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0),
{
if self.z == 0{
self.viewMap.camera = GMSCameraPosition.cameraWithTarget(self.markers[self.x!], zoom: 16.9)
print(self.markers.count)
if self.markers.count > 0 {
self.marker = GMSMarker(position: self.markers[0])
print(self.marker)
print(self.markers[0])
self.downloadVideo(self.marker)
}
}else{
}
});
dispatch_group_notify(groupVideo, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0),
{
if(self.tempLat!.roundToPlaces(3) == self.markerLat.roundToPlaces(3) && self.tempLong!.roundToPlaces(3) == self.markerLong.roundToPlaces(3)){
print("success")
self.postsLat = self.tempLat
self.postsLong = self.tempLong
}else {
print("not a success")
}
});
它们被初始化为:
let group: dispatch_group_t = dispatch_group_create();
let groupVideo: dispatch_group_t = dispatch_group_create();
然后进入和退出:
dispatch_group_enter(self.group);
dispatch_group_exit(self.group);
在两个单独的职能中
dispatch_group_enter(self.groupVideo);
dispatch_group_exit(self.groupVideo);