Apple 的“ QA:1702:How to capture video frames from the camera as images using AV Foundation ”在没有额外 ivar 代码的情况下被“破坏”。
我找到了解决办法——但什么是 ivar,在这种情况下它在做什么?
这是必须添加到 Apple 的 TestAVViewController.h 文件中的代码:
@interface TestAVViewController : UIViewController <AVCaptureVideoDataOutputSampleBufferDelegate>
@property AVCaptureSession *session;
@end
以下是必须添加到 Apple 的 TestAVViewController.m 文件的代码:
@implementation TestAVViewController
@synthesize session=ivarSession; // this creates an ivar
通过添加这两个部分(Apple 未提供),以下行将停止引发编译错误:
[self setSession:session];
防止编译错误的“session = ivarSession”是什么?为什么它能让苹果的代码工作?