我正在将我的应用从Swift升级到Swift 2并遇到以下错误:
'deviceInputWithDevice' is unavailable: use object construction 'AVCaptureDeviceInput(device:error:)'
以下是相关代码:
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)
}
有人可以帮我理解建议的解决方案:“使用对象构造'AVCaptureDeviceInput(device:error :)'”以及如何实现它?
答案 0 :(得分:18)
myage = 20;
varobj = {tvar: "myage"};
syncvar();
alert(thevar); // 20
myage = 100;
syncvar();
alert(thevar); // 100