开发者

&error error - iOS dev

开发者 https://www.devze.com 2023-03-18 10:30 出处:网络
I am trying to create an AVCaptureSession. I based my code on the WWDC 2011 video, number 419. I have the following line which is exactly the same as the code in the WWDC 2011 video and it also i开发

I am trying to create an AVCaptureSession. I based my code on the WWDC 2011 video, number 419.

I have the following line which is exactly the same as the code in the WWDC 2011 video and it also i开发者_运维知识库dentical to code here http://www.bardecode.com/en/knowledge-base/214-detailed-description-of-work-around-for-avcapturevideopreviewlayer-problem-in-ios-41.html

    // Create a device input with the device and add it to the session.
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device
                                                                    error:&error];

But Xcode says that the &error is the use of an undeclared identifier.


This is because you've not defined the NSError error variable, that you're providing the address of when you use &error.

If you define the variable via...

NSError *error = nil;

...on the line before, all should be well.

As a bit of an explanation, if you look at the signature for the AVCaptureDeviceInput deviceInputWithDevice:error: method you'll see the following:

+ (id)deviceInputWithDevice:(AVCaptureDevice *)device error:(NSError **)outError

In other words, this method expects the address of an NSError pointer variable to be provided as the ourError parameter.

0

精彩评论

暂无评论...
验证码 换一张
取 消