0
완료 처리기에 정수를 전달하고 싶습니다. 핸들러가 비동기 적이기 때문에 완료 핸들러가 실행될 때까지 count 값이 정확하지 않을 수 있습니다. count의 CURRENT 값을 핸들러에 전달하여 핸들러가 호출 될 때 카운트가 정확하도록하려고합니다. 어떻게해야합니까? 당신이 count
이 기능에는 선언이 없기 때문에Swift에서 완료 처리기에 값을 전달하는 방법은 무엇입니까?
// Take image
func didPressTakePhoto(){
if let videoConnection = stillImageOutput?.connection(withMediaType: AVMediaTypeVideo){
videoConnection.videoOrientation = AVCaptureVideoOrientation.portrait
count = count + 1
//Capture image. everything in this closure is ASYNCHRONOUS?
stillImageOutput?.captureStillImageAsynchronously(from: videoConnection, completionHandler: {
(sampleBuffer, error) in
//Do something with count...
})
}
}
전역 변수로 외부 계산을 선언했습니다. – bakalolo