? ? ? ?最近在項(xiàng)目中點(diǎn)擊系統(tǒng)導(dǎo)航的返回按鈕,程序總是莫名其妙的奔潰,直接跳轉(zhuǎn)到main函數(shù)就不動(dòng)了,控制臺(tái)輸出任何錯(cuò)誤信息:
NSScanner: nil string argument
NSScanner: nil string argument
libc++abi.dylib: terminate_handler unexpectedly threw an exception
在模擬器上不閃退,在真機(jī)上時(shí)不時(shí)閃退。谷歌一搜,有人說(shuō)這種情況大多是字符串操作異常,但是很難定位到底是在哪里出了問(wèn)題。也有人說(shuō)先把集成友盟的代碼注掉就可以在控制臺(tái)看到錯(cuò)誤信息了。果斷把友盟的代碼注掉,結(jié)果果然輸出了以下錯(cuò)誤信息:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x1495b06e0 of class YLCountChooser was deallocated while key value observers were still registered with it. Current observation info: (
Context: 0x0, Property: 0x1492642f0>
)'
這下終于看出點(diǎn)眉目了,原來(lái)是我這里定義的一個(gè)YLCountChooser通過(guò)KVO監(jiān)聽(tīng)了它的count屬性,而在釋放的時(shí)候沒(méi)有移除其observer。找到問(wèn)題就很好解決了,在代碼中將其observer移除就正常了。
參考:
Terminate_handler Unexpectedly Threw an Exception無(wú)法顯示崩潰原因和調(diào)用堆棧的分析及解決