मैं अपने ऐप को एक्सकोड 7 के साथ स्विफ्ट 2 में अपडेट कर रहा हूं। यह मेरा कंट्रोलर व्यूडिडलोड का कोड है।स्विफ्ट 2 कॉल व्यूडिडलोड छवि में अतिरिक्त तर्क त्रुटि
override func viewDidLoad() {
super.viewDidLoad()
// Get an instance of the AVCaptureDevice class to initialize a device object and provide the video
// as the media type parameter.
let captureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
// Get an instance of the AVCaptureDeviceInput class using the previous device object.
var error:NSError?
let input: AnyObject! = AVCaptureDeviceInput.deviceInputWithDevice(captureDevice, error: &error)
if (error != nil) {
// If any error occurs, simply log the description of it and don't continue any more.
print("\(error?.localizedDescription)")
return
}
// Initialize the captureSession object.
captureSession = AVCaptureSession()
// Set the input device on the capture session.
captureSession?.addInput(input as! AVCaptureInput)
// Initialize a AVCaptureMetadataOutput object and set it as the output device to the capture session.
let captureMetadataOutput = AVCaptureMetadataOutput()
captureSession?.addOutput(captureMetadataOutput)
// Set delegate and use the default dispatch queue to execute the call back
captureMetadataOutput.setMetadataObjectsDelegate(self, queue: dispatch_get_main_queue())
captureMetadataOutput.metadataObjectTypes = supportedBarCodes
// Initialize the video preview layer and add it as a sublayer to the viewPreview view's layer.
videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
videoPreviewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
videoPreviewLayer?.frame = view.layer.bounds
view.layer.addSublayer(videoPreviewLayer!)
// Start video capture.
captureSession?.startRunning()
// Move the message label to the top view
view.bringSubviewToFront(messageLabel)
// Initialize QR Code Frame to highlight the QR code
qrCodeFrameView = UIView()
qrCodeFrameView?.layer.borderColor = UIColor.greenColor().CGColor
qrCodeFrameView?.layer.borderWidth = 2
view.addSubview(qrCodeFrameView!)
view.bringSubviewToFront(qrCodeFrameView!)
}
लाइन
let input: AnyObject! = AVCaptureDeviceInput.deviceInputWithDevice(captureDevice, error: &error)
पर मैं कॉल में त्रुटि अतिरिक्त तर्क त्रुटि मिलती है। मैंने विधि से पहले ही कोशिश की है {} और पकड़ें {} लेकिन यह काम नहीं करता है, मुझे हमेशा यह त्रुटि मिलती है।
मैं इसे कैसे ठीक कर सकता हूं? धन्यवाद
स्विफ्ट 2 की नई सुविधाओं में से एक यह है कि यह 'एनएसईआरआरओ' सूचक को स्वीकार करने के बजाय फेंकता है, इसलिए यह संभवतः आपकी समस्या है। – sbarow
@ सबरो अच्छा नोट! – fqdn
@sbarow तो मैं इसे कैसे ठीक करता हूं? – markutus