Cocoa 无法使用AVAudioRecorder,com.apple.audio.IOThread.client上的访问错误

Cocoa 无法使用AVAudioRecorder,com.apple.audio.IOThread.client上的访问错误,cocoa,avfoundation,exc-bad-access,avaudiorecorder,metering,Cocoa,Avfoundation,Exc Bad Access,Avaudiorecorder,Metering,我正在开发一个简单的Cocoa应用程序,可以从AVAudioRecorder中检索仪表。 这是我的密码: @interface AppDelegate () <AVAudioRecorderDelegate> @property (weak) IBOutlet NSWindow *window; @property (strong) AVAudioRecorder *recorder; @property (strong) NSURL *dump; @end @implemen

我正在开发一个简单的Cocoa应用程序,可以从AVAudioRecorder中检索仪表。 这是我的密码:

@interface AppDelegate () <AVAudioRecorderDelegate>

@property (weak) IBOutlet NSWindow *window;
@property (strong) AVAudioRecorder *recorder;
@property (strong) NSURL *dump;

@end

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    NSDictionary *settings = @{AVSampleRateKey: @(44100.0),
                               AVNumberOfChannelsKey: @2,
                               AVFormatIDKey: @(kAudioFormatAppleLossless),
                               AVEncoderAudioQualityKey: @(AVAudioQualityHigh)
                               };
    NSError *error = nil;
    self.dump = [[NSURL alloc] initFileURLWithPath: [NSTemporaryDirectory() stringByAppendingString: @"dump"]];
    self.recorder = [[AVAudioRecorder alloc] initWithURL: self.dump
                                                settings: settings
                                                   error: &error];
    NSLog(@"Recorder, got error? %@", error);
    self.recorder.delegate = self;

    [self.recorder prepareToRecord];
    self.recorder.meteringEnabled = YES;
    [self.recorder record];
}

@end
@接口AppDelegate()
@属性(弱)窗口*窗口;
@属性(强)AVAudioRecorder*记录器;
@属性(强)NSURL*转储;
@结束
@实现AppDelegate
-(无效)ApplicationIDFinishLaunching:(NSNotification*)通知{
NSDictionary*设置=@{AVSampleRateKey:@(44100.0),
AVNumberOfChannelsKey:@2,
AVFormatIDKey:@(kAudioFormatAppleLossless),
AVEncoderAudioQualityKey:@(AVAudioQualityHigh)
};
n错误*错误=nil;
self.dump=[[NSURL alloc]initFileURLWithPath:[NSTemporaryDirectory()stringByAppendingString:@“dump”];
self.recorder=[[AVAudioRecorder alloc]initWithURL:self.dump
设置:设置
错误:&错误];
NSLog(@“记录器,出现错误?%@”,错误);
self.recorder.delegate=self;
[自我记录准备记录];
self.recorder.meteringEnabled=是;
[自记记录];
}
@结束
我还有一个计时器,每秒检索一次仪表。它在我的笔记本电脑上工作,但在我的iMac上,由于某种原因,我在调用record时无法访问“com.apple.audio.IOThread.client(8)”

有什么想法吗


谢谢

大概那台计算机的配置有问题。也许可以在一个新的干净用户中尝试。你可能有一个不好的插件、驱动程序等。无论如何,这与你的代码无关。我在mu笔记本电脑上构建了应用程序,并在我的iMac上运行了它,事实上,它工作正常,我不明白……好吧,那么当你访问不好时,这是在Xcode中运行的吗?换句话说,它是在笔记本电脑上运行,而不是在iMac上运行,还是独立运行,而不是在Xcode内运行?它是在我的笔记本电脑上的Xcode上运行的。但不是在我的iMac上。存档后,我可以在笔记本电脑和iMac上运行它。但如果你在iMac上构建并存档它,你可以在iMac上运行吗?