diff --git a/CHANGELOG.md b/CHANGELOG.md index 1671a5a..fd352e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,15 @@ # Change log +## [Version 5.4.0](https://github.com/yannickl/QRCodeReader.swift/releases/tag/5.4.0) +Released on 2016-01-24. + +- [REFACTORING] Rename `completionBlock` of `QRCodeReader` to `codeDidFoundBlock`. + ## [Version 5.3.1](https://github.com/yannickl/QRCodeReader.swift/releases/tag/5.3.1) Released on 2016-01-12. - [FIX] `value` and `type` of `QRCodeReaderResult` are not optional. -- [REFACTORING] rename `type` to `metadataType` in `QRCodeReaderResult`. +- [REFACTORING] Rename `type` to `metadataType` in `QRCodeReaderResult`. ## [Version 5.3.0](https://github.com/yannickl/QRCodeReader.swift/releases/tag/5.3.0) Released on 2016-01-11. diff --git a/QRCodeReader/QRCodeReader.swift b/QRCodeReader/QRCodeReader.swift index 1eb927a..db241df 100644 --- a/QRCodeReader/QRCodeReader.swift +++ b/QRCodeReader/QRCodeReader.swift @@ -29,7 +29,7 @@ import AVFoundation /// Reader object base on the `AVCaptureDevice` to read / scan 1D and 2D codes. public final class QRCodeReader: NSObject, AVCaptureMetadataOutputObjectsDelegate { - var defaultDevice: AVCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) + var defaultDevice: AVCaptureDevice = .defaultDeviceWithMediaType(AVMediaTypeVideo) var frontDevice: AVCaptureDevice? = { for device in AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo) { if let _device = device as? AVCaptureDevice where _device.position == AVCaptureDevicePosition.Front { @@ -58,15 +58,19 @@ public final class QRCodeReader: NSObject, AVCaptureMetadataOutputObjectsDelegat // MARK: - Managing the Properties /// CALayer that you use to display video as it is being captured by an input device. - public lazy var previewLayer: AVCaptureVideoPreviewLayer = { return AVCaptureVideoPreviewLayer(session: self.session) }() + public lazy var previewLayer: AVCaptureVideoPreviewLayer = { + return AVCaptureVideoPreviewLayer(session: self.session) + }() /// An array of strings identifying the types of metadata objects to process. public let metadataObjectTypes: [String] - // MARK: - Managing the Completion Block + // MARK: - Managing the Code Discovery + + //public var stopScanningWhenCodeIsFound: Bool = true /// Block is executing when a QRCode or when the user did stopped the scan. - public var completionBlock: (QRCodeReaderResult -> Void)? + public var codeDidFoundBlock: (QRCodeReaderResult -> Void)? // MARK: - Creating the Code Reader @@ -272,7 +276,7 @@ public final class QRCodeReader: NSObject, AVCaptureMetadataOutputObjectsDelegat let scannedResult = QRCodeReaderResult(value: _readableCodeObject.stringValue, metadataType:_readableCodeObject.type) dispatch_async(dispatch_get_main_queue(), { [weak self] in - self?.completionBlock?(scannedResult) + self?.codeDidFoundBlock?(scannedResult) }) } } diff --git a/QRCodeReader/QRCodeViewController.swift b/QRCodeReader/QRCodeViewController.swift index cf31765..407a688 100644 --- a/QRCodeReader/QRCodeViewController.swift +++ b/QRCodeReader/QRCodeViewController.swift @@ -128,7 +128,7 @@ public class QRCodeReaderViewController: UIViewController { view.backgroundColor = .blackColor() - codeReader.completionBlock = { [weak self] resultAsObject in + codeReader.codeDidFoundBlock = { [weak self] resultAsObject in if let weakSelf = self { weakSelf.completionBlock?(resultAsObject) weakSelf.delegate?.reader(weakSelf, didScanResult: resultAsObject)