添加自定义h和m文件iOS

时间:2017-05-10 16:29:35

标签: ios objective-c xcode

FlashHelper.m:

 #import "FlashHelper.h"

AVCaptureDevice* inputDevice;


@interface FlashHelper ()

@end

@implementation FlashHelper

-(id)init : (AVCaptureDevice*) device{
    self = [super init];
    inputDevice = device;
    return self;
}

-(void)turnOffFlash{
    [inputDevice lockForConfiguration:nil];
    [inputDevice setTorchMode:AVCaptureTorchModeOff];//turn on flash and test
    [inputDevice unlockForConfiguration];
}

-(void)turnOnFlash{
    [inputDevice lockForConfiguration:nil];
    [inputDevice setTorchMode:AVCaptureTorchModeOn];//turn on flash and test
    [inputDevice unlockForConfiguration];
}


@end

FlashHelper.h:

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>

@interface FlashHelper : NSObject {

}
-(id)init : (AVCaptureDevice*) device;
-(void)turnOffFlash;
-(void)turnOnFlash;

@end

我想将此作为帮助类添加到我当前的iOS项目中。我一直收到以下错误

Error

我对Objective-C相当新,任何帮助都会非常感激!

0 个答案:

没有答案