質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift 2

Swift 2は、Apple社が独自に開発を行っている言語「Swift」のアップグレード版です。iOSやOS X、さらにLinuxにも対応可能です。また、throws-catchベースのエラーハンドリングが追加されています。

Q&A

解決済

1回答

4938閲覧

下記のページと同じエラー(Extra argument error in call)で困っています。xcode7beta5でswift2を使用しています。

Aru.

総合スコア61

iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift 2

Swift 2は、Apple社が独自に開発を行っている言語「Swift」のアップグレード版です。iOSやOS X、さらにLinuxにも対応可能です。また、throws-catchベースのエラーハンドリングが追加されています。

0グッド

4クリップ

投稿2015/08/27 07:42

下記のページと同じエラー(Extra argument error in call)で困っています。xcode7beta5でswift2を使用しています。どのようにすればいいでしょうか?
http://www.stackoverflow.dluat.com/questions/31122985/swift-2-extra-argument-error-in-call-viewdidload-image

import UIKit import AVFoundation class ViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate { let session : AVCaptureSession = AVCaptureSession() var previewLayer : AVCaptureVideoPreviewLayer! var highlightView : UIView = UIView() override func viewDidLoad() { super.viewDidLoad() // Allow the view to resize freely self.highlightView.autoresizingMask = [UIViewAutoresizing.FlexibleTopMargin, UIViewAutoresizing.FlexibleBottomMargin, UIViewAutoresizing.FlexibleLeftMargin, UIViewAutoresizing.FlexibleRightMargin] // Select the color you want for the completed scan reticle self.highlightView.layer.borderColor = UIColor.greenColor().CGColor self.highlightView.layer.borderWidth = 3 // Add it to our controller's view as a subview. self.view.addSubview(self.highlightView) // For the sake of discussion this is the camera let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) // Create a nilable NSError to hand off to the next method. // Make sure to use the "var" keyword and not "let" var error: NSError? = nil //エラー箇所↓(Extra argument error in call) let input = AVCaptureDeviceInput.deviceInputWithDevice(device, error: &error) as AVCaptureDeviceInput // If our input is not nil then add it to the session, otherwise we're kind of done! if input != nil { session.addInput(input) } else { // This is fine for a demo, do something real with this in your app. :) print(error) } let output = AVCaptureMetadataOutput() output.setMetadataObjectsDelegate(self, queue: dispatch_get_main_queue()) session.addOutput(output) output.metadataObjectTypes = output.availableMetadataObjectTypes previewLayer = AVCaptureVideoPreviewLayer(layer: session) as AVCaptureVideoPreviewLayer previewLayer.frame = self.view.bounds previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill self.view.layer.addSublayer(previewLayer) // Start the scanner. You'll have to end it yourself later. session.startRunning() } // This is called when we find a known barcode type with the camera. func captureOutput(captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, fromConnection connection: AVCaptureConnection!) { var highlightViewRect = CGRectZero var barCodeObject : AVMetadataObject! var detectionString : String! let barCodeTypes = [AVMetadataObjectTypeUPCECode, AVMetadataObjectTypeCode39Code, AVMetadataObjectTypeCode39Mod43Code, AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeCode93Code, AVMetadataObjectTypeCode128Code, AVMetadataObjectTypePDF417Code, AVMetadataObjectTypeQRCode, AVMetadataObjectTypeAztecCode ] // The scanner is capable of capturing multiple 2-dimensional barcodes in one scan. for metadata in metadataObjects { for barcodeType in barCodeTypes { if metadata.type == barcodeType { barCodeObject = self.previewLayer.transformedMetadataObjectForMetadataObject(metadata as! AVMetadataMachineReadableCodeObject) highlightViewRect = barCodeObject.bounds detectionString = (metadata as! AVMetadataMachineReadableCodeObject).stringValue self.session.stopRunning() break } } } print(detectionString) self.highlightView.frame = highlightViewRect self.view.bringSubviewToFront(self.highlightView) } }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

掲載していただいたリンクの対応はすで試されていますか?

Swift2からはエラーハンドリングが変わったので引数にerrorを取る方法ではなくてtry catchで実装すれば良いというようなことが書いてありますが、、、

これの代わりに

let input = AVCaptureDeviceInput.deviceInputWithDevice(device, error: &error) as AVCaptureDeviceInput

これを実装する

do { let captureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) let input = try AVCaptureDeviceInput(device: captureDevice) // Do the rest of your work... } catch let error as NSError { // Handle any errors print(error) }

投稿2015/08/28 03:28

jollyjoester

総合スコア1585

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問