如何在Objective-C中更改BOOL的值? lightOn
是我需要帮助修改的BOOL
值。
@synthesize button, view;
-(IBAction)torchOn:(id)sender;
{
AVCaptureDevice*flashlight = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if([flashlight isTorchAvailable] && [flashlight isTorchModeSupported:AVCaptureTorchModeOn] && [lightOn = YES])
{
BOOL success [[flashlight lockForConfiguration:nil]];
if(success)
{
[flashlight setTorchMode:AVCaptureTorchModeOn];
[flashlight unlockForConfiguration];
lightOn = NO;
}
}
}
答案 0 :(得分:2)
Objective-C扩展了ANSI C语言。开始在那里学习。 Here's a primer
BOOL amICrazy;
amICrazy = YES;
// amICrazy = NO;
if (amICrazy == YES)
[self seekHelp];
答案 1 :(得分:2)
BOOL success [[flashlight lockForConfiguration:nil]];
是毫无意义的陈述。
即使我将[[flashlight lockForConfiguration:nil]]
视为[flashlight lockForConfiguration:nil]
,但lockForConfiguration:
方法应返回BOOL
值。
然后可以通过以下方式将该值分配给成功:
BOOL success = [flashlight lockForConfiguration:nil];