Skip to content

_metadataObjectTypes is staying nil and crash app. #27

@humbertosales

Description

@humbertosales

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions