Question

I am trying to let the users record their voice in my app and I am following this tutorial. This is the code in viewDidLoad:

NSArray *dirPaths;
NSString *docsDir;

dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];

NSString *soundFilePath = [docsDir
                           stringByAppendingPathComponent:@"sound.caf"];

NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];

NSDictionary *recordSettings = [NSDictionary
                                dictionaryWithObjectsAndKeys:
                                [NSNumber numberWithInt:AVAudioQualityMin],
                                AVEncoderAudioQualityKey,
                                [NSNumber numberWithInt:16],
                                AVEncoderBitRateKey,
                                [NSNumber numberWithInt: 2],
                                AVNumberOfChannelsKey,
                                [NSNumber numberWithFloat:44100.0],
                                AVSampleRateKey,
                                nil];

NSError *error = nil;

self.recorder = [[AVAudioRecorder alloc]
                  initWithURL:soundFileURL
                  settings:recordSettings
                  error:&error];

if (error)
{
    NSLog(@"error: %@", [error localizedDescription]);
} else {
    [self.recorder prepareToRecord];
} 

I am getting 6 errors:

I know the errors are coming from the the code in viewDidLoad because when I comment out that code the errors go away. What do the errors mean and how do I fix it?

Was it helpful?

Solution

"Normally" this kind of error are related to the fact that the linker is not able to find a framework that you reference from your code, in your case the issue I guess is that you did not link your project against AVFoundation. So Adding the framework in your build phases should fix the issue

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top