2015-06-20 18 views
11

Ben Swift 2 Swift benim app "yükseltme" ve takip hatası geldi ediyorum:"deviceInputWithDevice kullanılamıyor" hatasını nasıl düzeltirim?

let captureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) 
    var input:AVCaptureDeviceInput 
    let error:NSError? 

    do { 
     let input = try AVCaptureDeviceInput.deviceInputWithDevice(captureDevice) as AVCaptureDeviceInput 
    } catch let error as NSError { 
     print(error) 
    } 

biri bana önerilen çözüm anlamak yardımcı olabilir: Burada 'deviceInputWithDevice' is unavailable: use object construction 'AVCaptureDeviceInput(device:error:)'

söz konusu kodudur : "nesne yapısını kullan" AVCaptureDeviceInput (aygıt: error :) '"ve nasıl uygulayabilirim lütfen?

cevap

18
do { 
     let input = try AVCaptureDeviceInput(device: captureDevice) as AVCaptureDeviceInput 
     // moved the rest of the image capture into the do{} scope. 
+1

Hatayı nasıl ele alıyorsunuz? – daidai

+1

bulunamadı '' 'NSError { println (error)}' 'olarak hatayı yakala – daidai