2012-08-06 30 views
2

在我的應用程序的一開始,我嘗試加載每個UIDocument以獲取其內容的一些預覽。這在大多數情況下都能很好地工作,但是有時在加載UIDocument後我會立即崩潰。我的問題是我不知道如何解釋崩潰。我甚至不知道它是否與處理UIDocument有關(線程6和7與UIDoc有關,但線程8似乎導致了崩潰)。與UIDocument相關的EXC_BAD_ACCESS

如果有人可以幫助我來解釋這一點,我會非常感激:

enter image description here

我對所有異常斷點,但調試器不會在特定的代碼行停止。

+0

控制檯中的錯誤是什麼,你能證實你成功地打開了你的'UIDocument'嗎? (很多操作都是異步的) – aforaudrey 2012-08-06 06:51:07

+1

@iBlue在控制檯中根本沒有輸出。 UIDoc未成功打開,即我在openWithCompletionHandler的成功塊中所做的事情:^(BOOL成功)未執行。它之前崩潰了。所以我想我提供的崩潰截圖並沒有真正說明錯誤來源,是嗎? – 2012-08-06 07:34:27

+1

@ n.evermind,我也有類似的問題......你能告訴我們你是如何修復它的嗎?這對我很有幫助。 – Ananth 2013-01-22 14:04:45

回答

0

我有同樣的問題。只需使用我們的一臺測試設備即可輕鬆讀取iCloud文檔。重新安裝該應用程序不會影響該錯誤。

我正在使用NSMetadataQuery來獲取文件URL。我對NSMetadataQueryDidFinishGatheringNotification接收器看起來像這樣:

- (void)queryDidFinishGathering:(NSNotification *)notification 
{ 
    NSMetadataQuery *query = [notification object]; 
    [query disableUpdates]; 
    [query stopQuery]; // <--- This was the problem 

    NSMetadataItem *item = [query resultAtIndex:0]; 
    NSURL *url = [item valueForAttribute:NSMetadataItemURLKey]; 
    UIDocument *doc = [[CustomDocument alloc] initWithFileURL:url]; 
    [doc openWithCompletionHandler:^(BOOL success) { 
     // EXC_BAD_ACCESS before completion block is called :'(
    }]; 

    [query enableUpdates]; 
} 

卸下stopQuery呼叫固定的一切!