代码之家  ›  专栏  ›  技术社区  ›  azamsharp

在IPhone中创建AVAudioRecorder实例

  •  0
  • azamsharp  · 技术社区  · 14 年前

    我在控制器实现文件中使用以下代码来创建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; 
    
    }
    

    它一直给我以下错误:

    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
    

    #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 回复  |  直到 14 年前