2011-12-12 70 views
0

“错误访问”这是我的代码:canSetSessionPreset:AVCaptureSessionPreset1920x1080原因,iOS4的

 
if([self.captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080] == YES) 
    { 
    [self.captureSession setSessionPreset:AVCaptureSessionPreset1920x1080]; 
    self.currentPreset = GMCVideoCaptureRecordingPresetFullHD; 
    } 

在iOS4的停止执行与“坏访问”错误的第一道防线。 在iOS5上,它工作正常。

如何正确检查兼容性?

回答

4

AVCaptureSessionPreset1920x1080NSString *const。你可以检查它的地址是不是NULL。所以像这样:

if(&AVCaptureSessionPreset1920x1080 != NULL && [self.captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080] == YES) 
{ 
    [self.captureSession setSessionPreset:AVCaptureSessionPreset1920x1080]; 
    self.currentPreset = GMCVideoCaptureRecordingPresetFullHD; 
} 

这应该做你想做的。请注意,您不会在iOS 5上设置<预设,但您可能需要else来处理iOS 5的<或无法设置1920x1080预设。

+0

谢谢!我试图检查AVCaptureSessionPreset1920x1080对零,这是错误的做法。 – AlexeyVMP