QRCodeReaderViewController icon indicating copy to clipboard operation
QRCodeReaderViewController copied to clipboard

_metadataObjectTypes is staying nil and crash app.

Open humbertosales opened this issue 8 years ago • 1 comments

Yannick,

I has one problem and make some adjusts (workaround). Please, see.

The _metadataObjectTypes is always nil. QRCodeReader.m

- (id)init
{
  if ((self = [super init])) {
    _metadataObjectTypes = @[AVMetadataObjectTypeQRCode]; //not work. _metadataObjectTypes  will continue nil

    [self setupAVComponents];
    [self configureDefaultComponents];
  }
  return self;
}

- (id)initWithMetadataObjectTypes:(NSArray *)metadataObjectTypes
{
  if ((self = [super init])) {
    self.metadataObjectTypes = metadataObjectTypes; //not work. _metadataObjectTypes  will continue nil.

    [self setupAVComponents];
    [self configureDefaultComponents];
  }
  return self;
}

Workaround: QRCodeReader.m

@interface QRCodeReader () <AVCaptureMetadataOutputObjectsDelegate>
@property (strong, nonatomic) AVCaptureDevice            *defaultDevice;
@property (strong, nonatomic) AVCaptureDeviceInput       *defaultDeviceInput;
@property (strong, nonatomic) AVCaptureDevice            *frontDevice;
@property (strong, nonatomic) AVCaptureDeviceInput       *frontDeviceInput;
@property (strong, nonatomic) AVCaptureMetadataOutput    *metadataOutput;
@property (strong, nonatomic) AVCaptureSession           *session;
@property (strong, nonatomic) AVCaptureVideoPreviewLayer *previewLayer;

@property (strong, nonatomic) NSArray *metadataObjectTypes; //ADDED

And replace all _ metadataObjectTypes for self. metadataObjectTypes in QRCodeReader.m.

Now it works!

humbertosales avatar Nov 10 '16 13:11 humbertosales

@humbertosales Thank you for the hint. I'll investigate that when I'll have some time.

yannickl avatar Nov 11 '16 13:11 yannickl