Reputation: 27
So I have a code to start recording audio and keep getting the above warning message. any help?
- (IBAction)recordStart:(id)sender {
AVAudioSession *recSession1 = [[AVAudioSession alloc] init];
[recSession1 setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
[recorder1 prepareToRecord];
[recorder1 record];
}
Upvotes: 0
Views: 1457
Reputation: 318804
If you read the documentation for AVAudioSession
you will see that it is a singleton. You are not supposed to create your own instances. Use the sharedInstance
method.
- (IBAction)recordStart:(id)sender {
AVAudioSession *recSession1 = [AVAudioSession sharedInstance];
[recSession1 setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
[recorder1 prepareToRecord];
[recorder1 record];
}
The error you are getting is now there to ensure that you access the shared instance properly instead of attempting to create your own instance.
Upvotes: 2