2011-12-13 46 views
1

[recorder deleteRecording];運行良好30次,但大約31次崩潰。爲什麼deleteRecording崩潰(AVAudioRecorder,iOS)?

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 
+0

它看起來像你是過度釋放你的對象。但是,如果您沒有發佈任何代碼,則很難回答 –

+0

我不會自己發佈任何內容,只需使用AVAudioRecorder框架即可。也許記錄器在刪除之前已經釋放了嗎?但我有記錄器保留,我無意釋放它... – Geri

+0

我討厭框架方法去後臺線程,沉重的調試與他們。 – Geri

回答

2

我發現這種情況發生在deleteRecording嘗試刪除不存在的文件時。因此,請在調用之前檢查文件是否存在:

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

它必須是AVAudioRecorder中的一個錯誤。