//1. 实例化拍摄设备
AVCaptureDevice*device = [AVCaptureDevicedefaultDeviceWithMediaType:AVMediaTypeVideo];
//2. 设置输入设备
AVCaptureDeviceInput*input = [AVCaptureDeviceInputdeviceInputWithDevice:deviceerror:nil];
//3. 设置元数据输出
//3.1 实例化拍摄元数据输出
AVCaptureMetadataOutput*output = [[AVCaptureMetadataOutputalloc] init];
//3.3 设置输出数据代理
[outputsetMetadataObjectsDelegate:selfqueue:dispatch_get_main_queue()];
//4. 添加拍摄会话
//4.1 实例化拍摄会话
AVCaptureSession*session = [[AVCaptureSessionalloc] init];
//4.2 添加会话输入
[sessionaddInput:input];
//4.3 添加会话输出
[sessionaddOutput:output];
//4.3 设置输出数据类型,需要将元数据输出添加到会话后,才能指定元数据类型,否则会报错
[outputsetMetadataObjectTypes:@[AVMetadataObjectTypeQRCode]];