我正在学习Objective C,并且正在学习本书中的示例。但是在某些示例中,我不断收到此错误!我完全按照步骤操作,请帮助!我已经尝试将 iOS 模拟器恢复为其默认设置,但仍然没有运气。
这是一个应用程序,您可以在其中录制声音并播放。这是代码...
- (IBAction)recordAudio:(id)sender {
if ([self.recordButton.titleLabel.text isEqualToString:@"Record Audio"]){
[self.audioRecorder record];
[self.recordButton setTitle:@"Stop Recording"
forState:UIControlStateNormal];
} else {
[self.audioRecorder stop];
[self.recordButton setTitle:@"Record Audio"
forState:UIControlStateNormal];
// Load the new sound in the audioplayer for playback
NSURL *soundFileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory()
stringsByAppendingPaths:@"sound.caf"]];
self.audioPlayer = [[AVAudioPlayer alloc]
initWithContentsOfURL:soundFileURL error:nil];
}
}