azamsharp
azamsharp

Reputation: 20066

Creating AVAudioRecorder Instance in IPhone

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

Upvotes: 0

Views: 724

Answers (1)

Art Gillespie
Art Gillespie

Reputation: 8757

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

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

alt text http://img.skitch.com/20100726-1pcyc79tnemqqegnram758w9q3.png

alt text http://img.skitch.com/20100726-m3j8ceei4k8w5m2cxwj9ct41us.png

Upvotes: 1

Related Questions