0
我正在創建一個iOS應用程序,在發生提示時開始錄製音頻,而不是按下按鈕時。因此,我將AVAudioRecorder放置在一個調度程序對象中,該對象從它自己的類中調用。但是,當我將調度程序指定爲記錄儀的代表時,我收到的警告指定爲'id<AVAudioRecorderDelegate>' from incompatible type 'LWPScheduler *__strong'
。下面是調度的實現:將AVAudioRecorderDelegate分配給非UIViewController
@implementation LWPScheduler
@synthesize tempo;
@synthesize userName;
+(LWPScheduler *)masterScheduler{
static LWPScheduler *masterScheduler = nil;
if (masterScheduler == nil)
{
masterScheduler = [[self alloc] init];
}
return masterScheduler;
}
- (id)init
{
self = [super init];
if (self) {
self.tempo = 120;
self.userName = @"Tim Burland";
//recording init
// Set the audio file
NSArray *pathComponents = [NSArray arrayWithObjects:
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject],
@"MyAudioMemo.m4a",
nil];
NSURL *outputFileURL = [NSURL fileURLWithPathComponents:pathComponents];
//audio session
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
//recorder settings
NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
// Initiate and prepare the recorder
_recorder = [[AVAudioRecorder alloc] initWithURL:outputFileURL settings:recordSetting error:NULL];
_recorder.delegate = self; //Incompatible Type Warning Here
_recorder.meteringEnabled = YES;
[_recorder prepareToRecord];
}
return self;
}
@end
我的問題是我是否必須遷移記錄將被包含在感謝您的幫助音頻處理控制器的看法!
輔助問題:在自己的類文件中存在的對象的術語是什麼? – Kadinski
我不明白輔助問題... – nhgrif
例如,'[NSFileManager defaultManager]',或在這種情況下,'[LWPScheduler masterScheduler]' – Kadinski