objective-c二维码的扫码与生成
1.扫描二维码
获取输入设备(当前是摄像头)
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
根据输入设备获取输入对象
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil];
创建输出对象
AVCaptureMetadataOutput *output = [AVCaptureMetadataOutput new];
设置代理监听对象输出的数据,在主线程回调
[output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
创建会话
AVCaptureSession *session = [AVCaptureSession new];