2012-03-19 26 views
-1

我正在研究一個簡單的iOS應用,我已經接管了工作。我添加了一個具有UIWebView並從表視圖導航到的控制器。我能夠做的就可以了pushViewController但是當我向後導航,應用程序崩潰,在這裏:iOS應用崩潰 - 不確定接下來要看的是什麼

- (void)dealloc 
{ 
    myWebView.delegate = nil; // Thread 1 stopped at breakpoint 1 
} 

在控制檯,它說:

[Switching to process 621 thread 0x13b03] 
[Switching to process 621 thread 0x18703] 
[Switching to process 621 thread 0x11903] 

很顯然,我做了一些錯誤但需要下一個地方看看?我正在使用ARC。

THX

編輯1

This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all 
Attaching to process 974. 
Pending breakpoint 1 - ""WebViewController.m":57" resolved 
2012-03-19 08:11:05.888 SpotFinder[974:11903] Latitude = 37.785834 
2012-03-19 08:11:05.889 SpotFinder[974:11903] Latitude = -122.406417 
2012-03-19 08:11:06.030 SpotFinder[974:11903] here is a log of places 33 
2012-03-19 08:11:11.030 SpotFinder[974:11903] You selected index_path: <NSIndexPath 0x705c0d0> 2 indexes [0, 2] 
[Switching to process 974 thread 0x13a03] 
[Switching to process 974 thread 0x15e03] 
[Switching to process 974 thread 0x13a03] 
[Switching to process 974 thread 0x11903] 
Current language: auto; currently objective-c 
(gdb) 

編輯2 堆棧跟蹤:

enter image description here

+0

這些控制檯消息是不相關的。它在控制檯中還說了些什麼? – mattjgalloway 2012-03-19 15:03:03

+0

@timpone [Stack trace](http://stackoverflow.com/a/5660248/296387)? [殭屍啓用](http:// 42games。淨/快音符上設置-nszombieenabled環境變量功能於Xcode中-4 /)? [爲所有例外集設置的斷點](http://developer.apple.com/library/mac/documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/Debugging/Debugging.html#//apple_ref/doc/uid/TP40010215-CH3-SW38 )? – 2012-03-19 15:10:26

+0

嗯...我得到'ARC禁止dealloc明確的消息發送' – timpone 2012-03-19 15:17:20

回答

0

永遠不要叫dealloc的直接無論是在非ARC環境或啓用ARC。

在非ARC中調用release,則dealloc由系統在該特定對象上調用。

當啓用ARC的Dealloc在該對象上沒有任何引用時被調用(同樣,由系統)。

+0

呃 - 趾高氣揚地說這個,但是當我開始查看行號時,我意識到有第二個斷點,而且應用程序實際上並沒有崩潰。只是在斷點處凍結。我的錯。 Thx幫助大家 – timpone 2012-03-19 15:34:08

0

使用ARC時,您可以定義一個dealloc方法來刪除引用並清理資源,但不應該明確地調用[super dealloc]

請參閱ARC Enforces New Rules它是Transitioning to ARC Release Notes的一部分。

你不能顯式調用的dealloc,或實施或調用保留, 釋放,retainCount,或自動釋放。禁止擴展到使用 @selector(保留),@選擇器(發佈)等。

如果您需要管理除釋放實例變量之外的資源 ,則可以實施dealloc方法。您不必(實際上 您不能)釋放實例變量,但您可能需要在系統類和其他代碼 上調用 [systemClassInstance setDelegate:nil],該代碼不使用ARC編譯。

ARC中的自定義dealloc方法不需要調用[super dealloc] (它實際上會導致編譯器錯誤)。鏈接超級是 自動化並由編譯器強制執行。

您仍然可以使用CFRetain,CFRelease,以及其他相關功能 與核心基礎樣式對象(請參閱「管理免費電話 橋接」)。