tags:

views:

65

answers:

1

I am using the following code in my controller implementation file to create the instance of AVAudioRecorder.

-(NSError *) createAVAudioRecorder 
{
 [recorder release];
 recorder = nil; 

 NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0]; 
 NSString *calDate = [now description]; 

 NSString *fileName = [NSString stringWithFormat:@"myfile"]; 


 NSLog(@"%@\%@",DOCUMENTS_FOLDER,calDate); 

 NSString *recorderFilePath = [[NSString stringWithFormat:@"%@/%@.caf",DOCUMENTS_FOLDER, fileName] retain]; 

 NSURL *url = [NSURL fileURLWithPath:recorderFilePath]; 

 NSMutableDictionary *recordSettings = [[NSMutableDictionary alloc]init]; 

 NSError *err = nil; 

 recorder = [[AVAudioRecorder alloc] initWithURL:url settings:recordSettings error:&err]; 

 return nil; 

}

And it keep giving me the following error:

Undefined symbols:
  "_OBJC_CLASS_$_AVAudioRecorder", referenced from:
      objc-class-ref-to-AVAudioRecorder in myapp.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

The header file looks like this:

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreAudio/CoreAudioTypes.h> 



@interface MyController : UIViewController<AVAudioRecorderDelegate> {

 IBOutlet UIButton *recordButton; 
 AVAudioRecorder *recorder; 

}

-(IBAction) record: (id) sender; 
-(NSError *) createAVAudioRecorder; 


@end
+1  A: 

Have you added 'AVFoundation.framework' to your project?

EDIT Here's how you add frameworks to your project.

alt text

alt text

Art Gillespie
Also keep in mind that AVFoundation is not in the iphone simulator
Daniel
You kidding me right!! Then does that mean I can only test AVFoundation using the actual device :(
azamsharp
@Daniel but I should still be able to create the instance successfully which I am not!
azamsharp
No, AVFoundation.framework is available in the iPhone Simulator.
Art Gillespie
I have updated my code. I am not sure what I am doing wrong!
azamsharp
You're linking to the framework?
Art Gillespie
How should I do that? I am not sure how to add AVFoundation.framework?
azamsharp
I've edited my answer with Xcode screenshots.
Art Gillespie
Awesome man! I have three different books and none of them told me to add the reference.
azamsharp