gpt4 book ai didi

iphone - 为什么deleteRecording崩溃了(AVAudioRecorder,iOS)?

转载 作者:行者123 更新时间:2023-12-03 20:53:07 25 4
gpt4 key购买 nike

[录音机删除录音]; 30 次运行良好,但大约 31 次就崩溃了。

0   libobjc.A.dylib                 0x3266fc98 objc_msgSend + 16
1 Foundation 0x328c203c -[NSError dealloc] + 36
2 CoreFoundation 0x30d2dc3c -[NSObject(NSObject) release] + 24
3 Foundation 0x328e687c -[NSFilesystemItemRemoveOperation dealloc] + 36
4 Foundation 0x328bc7b2 -[NSOperation release] + 38
5 CoreFoundation 0x30d2e19a CFRelease + 62
6 CoreFoundation 0x30d30eb4 _CFAutoreleasePoolPop + 140
7 Foundation 0x328abbae NSPopAutoreleasePool + 2
8 Foundation 0x3293a908 __NSThreadPerformPerform + 620
9 CoreFoundation 0x30da0a72 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
10 CoreFoundation 0x30da2758 __CFRunLoopDoSources0 + 376
11 CoreFoundation 0x30da34e4 __CFRunLoopRun + 224
12 CoreFoundation 0x30d33ebc CFRunLoopRunSpecific + 224
13 CoreFoundation 0x30d33dc4 CFRunLoopRunInMode + 52
14 GraphicsServices 0x31896418 GSEventRunModal + 108
15 GraphicsServices 0x318964c4 GSEventRun + 56
16 UIKit 0x355b9d62 -[UIApplication _run] + 398
17 UIKit 0x355b7800 UIApplicationMain + 664
18 AppName 0x000020f6 main (main.m:16)
19 AppName 0x00002050 start + 44

最佳答案

我发现当deleteRecording尝试删除不存在的文件时会发生这种情况。因此,在调用文件之前检查文件是否存在:

if ([[NSFileManager defaultManager] fileExistsAtPath:self.recorder.url.path]) {
if (![self.recorder deleteRecording])
NSLog(@"Failed to delete %@", self.recorder.url);
}

这一定是 AVAudioRecorder 中的错误。

关于iphone - 为什么deleteRecording崩溃了(AVAudioRecorder,iOS)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8491968/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com