I am recording audio in my app. The app runs in my iPhone 5C with iOS 7 just fine, but it fails in the simulator (iPhone Retina 3,5-inch / 4-inch/ 4-inch 64 bit)
Here is the code to setup audio:
-(void)setupAudio{
_audioMessageLabel.text = @"...Bereit für Aufnahme...";
[_stopButton setEnabled:NO];
[_playButton setEnabled:NO];
// Set the audio file
NSString *guid = [[NSUUID new] UUIDString];
_dateiName = [NSString stringWithFormat:@"audio-notiz-%@.m4a", guid];
NSLog(@"dateiName: %@", _dateiName);
NSArray *pathComponents = [NSArray arrayWithObjects:
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject],
_dateiName,
nil];
_outputFileURL = [NSURL fileURLWithPathComponents:pathComponents];
// Setup audio session
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
// Define the recorder setting
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
NSError *error = nil;
recorder = [[AVAudioRecorder alloc] initWithURL:_outputFileURL settings:recordSetting error:&error];
if (error)
{
NSLog(@"error: %@", [error localizedDescription]);
} else {
recorder.delegate = self;
recorder.meteringEnabled = YES;
[recorder prepareToRecord];
}
}
It fails in the last line [recorder prepareToRecord]
with (lldb) in the console