AVAudioRecorder en iOS 9 no funciona

Estoy usando AVAudioRecorder para grabar un file de audio. El código que estoy usando funciona perfectamente bien en iOS 8 y versiones posteriores, pero desde la última actualización de iOS 9, la grabación parece haber dejado de funcionar.

Intenté registrar las properties del object AVAudioRecorder e incluso después de llamar a la function "grabar" en AVAudioRecorder isRecording aparece como NO y cuando se llama a la function "detener", - (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag; la llamada en el delegado - (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag; con la bandera de éxito como NO

 audioSession = [AVAudioSession shanetworkingInstance]; NSError *err = nil; [audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err]; if(err){ NSLog(@"audioSession: %@ %ld %@", [err domain], (long)[err code], [[err userInfo] description]); return; } [audioSession setActive:YES error:&err]; recordSetting = [[NSMutableDictionary alloc] init]; [recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey]; [recordSetting setValue:[NSNumber numberWithFloat:16000.0] forKey:AVSampleRateKey]; [recordSetting setValue:[NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey]; [recordSetting setValue :[NSNumber numberWithInt:16] forKey:AVEncoderBitRateKey]; [recordSetting setValue :[NSNumber numberWithInt:8] forKey:AVLinearPCMBitDepthKey]; [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey]; [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey]; [recordSetting setValue :[NSNumber numberWithInt:AVAudioQualityMin] forKey:AVEncoderAudioQualityKey]; recorderFilePath = [NSString stringWithFormat:@"%@/%@.m4a", DOCUMENTS_FOLDER,@"sample"]; NSLog(@"RecorderFilePath : %@",recorderFilePath); NSURL *url = [NSURL fileURLWithPath:recorderFilePath]; err = nil; recorder = [[ AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:&err]; //prepare to record [recorder setDelegate:self]; [recorder prepareToRecord]; recorder.meteringEnabled = YES; BOOL audioHWAvailable = audioSession.inputAvailable; [recorder record]; 

Por favor, avisa si estoy haciendo algo mal en el código.

Prueba esto:

  AVAudioSession *session = [AVAudioSession shanetworkingInstance]; [session setCategory:AVAudioSessionCategoryRecord error:nil]; // Define the recorder setting NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey, [NSNumber numberWithFloat:44100.0], AVSampleRateKey, [NSNumber numberWithInt: 2], AVNumberOfChannelsKey,nil]; // [recordSetting setValue :[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey]; // Initiate and prepare the recorder if (recorderHelium) { recorderHelium = nil; } recorderHelium = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:recordedAudioFilePath] settings:recordSetting error:nil]; recorderHelium.delegate = self; recorderHelium.meteringEnabled = YES; [recorderHelium prepareToRecord]; [recorderHelium record]; 

Y también importar e include estos files:

 #import <AudioToolbox/AudioServices.h> #include <AudioToolbox/AudioToolbox.h>