Iphone 正在尝试使用AVAudioRecorder,调试时出现异常

Iphone 正在尝试使用AVAudioRecorder,调试时出现异常,iphone,objective-c,xcode,ios5,avaudiorecorder,Iphone,Objective C,Xcode,Ios5,Avaudiorecorder,我正在尝试使用下面的代码为iphone创建一个简单的音频录制器,带有开始和停止按钮 编译工作正常,但是当我试着调试程序并按下开始按钮时,我得到了thread1:Trace,在它显示“error:nil];” 我甚至不知道该如何开始弄清楚这意味着什么。顺便说一下,这将是第一次使用objective-c和xcode // Start recording or warn that already started - (IBAction)startButton_clicked:(id)sender {

我正在尝试使用下面的代码为iphone创建一个简单的音频录制器,带有开始和停止按钮

编译工作正常,但是当我试着调试程序并按下开始按钮时,我得到了thread1:Trace,在它显示“error:nil];”

我甚至不知道该如何开始弄清楚这意味着什么。顺便说一下,这将是第一次使用objective-c和xcode

// Start recording or warn that already started
- (IBAction)startButton_clicked:(id)sender {
    if (currentlyRecording == false)
    {
        // Sets recorder settings
        [[AVAudioSession sharedInstance]
         setCategory: AVAudioSessionCategoryRecord
         error: nil];
        NSDictionary *recordSettings =
        [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithFloat: 44100.0], AVSampleRateKey,
         [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
         [NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
         [NSNumber numberWithInt: AVAudioQualityMax],
         AVEncoderAudioQualityKey, nil];
        // Determine file name
        NSString *fileDir = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
        NSString *filePath = [NSString stringWithFormat:@"%@/%@.wav", fileDir , GetCurrentTime()];
        //debugText.text = [NSString stringWithFormat:@"%@", filePath]; // DEBUGGING

         // Prepare recording
         soundFileURL = [[NSURL alloc] initWithString:filePath];
         AVAudioRecorder *newRecorder =
         [[AVAudioRecorder alloc] initWithURL: soundFileURL
         settings: recordSettings
         error: nil];
         [recordSettings release];
         soundRecorder = newRecorder;
         [newRecorder release];

         // Record
         [soundRecorder prepareToRecord];
         [soundRecorder record];
         currentlyRecording = true;
         headLabel.text = @"Started";
    }

    // if currentlyrecording is already true
    else headLabel.text = @"Already Started";
}


// stops recording or warns that already stopped
- (IBAction)stopButton_clicked:(id)sender {
    if (currentlyRecording == true)
    {
        // Stop recording & clear vars
        [soundRecorder stop];
        soundRecorder = nil;
        currentlyRecording = false;
        headLabel.text = @"Stopped";
    }

    // if currentlyrecording is already false
    else headLabel.text = @"It's not even on!";
}

我也遇到了类似的问题。我在[AVAudioSession sharedInstance]上单独获得一个异常断点,控制台窗口中没有异常。但是,我在控制台输出中得到了以下结果:

<com.apple.main-thread> AddPropertyListenerImp posting message to kill mediaserverd (0)
AddPropertyListenerImp向杀死mediaserverd(0)发布消息
我也在我的应用程序中记录,但当我的记录出现故障并重新启动应用程序时,我得到了这个信息。因此,这是应用程序的一次新运行——但显然,由于之前发生的事情,该设备已进入问题状态


希望这会有所帮助-我知道这不是一个解决方案的直接答案,但我想让大家了解更多。

如果您希望我们帮助您消除异常,也许最好先告诉我们您作为异常的情况是什么?