純屬個人總結
EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0) 這種崩潰有時無任何徵兆,我們可以打開Product->Scheme->Edit Scheme 按照如下圖操作:
run->Diagnostics->Enable Zombie Objects 勾選上
重新定位問題,觀察控制檯是否有提示輸出
如果沒有繼續以下操作(用模擬器調試):
1.還是Edit Scheme,切換到Tab Aguments 配置環境變量MallocStackLoggingNoCompact,NSZombieEnabled,MallocStackLogging
重新定位問題,錯位信息裏會有一個內存地址,例如:message sent to deallocated instance 0x6497860, 在終端裏輸入malloc_history 40888 0x6497860 |grep 0x6497860 會出現以下提示
ALLOC 0xfcdff50-0xfce00b7 [size=360]: thread_3bf2a28 |start | main | UIApplicationMain | GSEventRun
| GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoObservers
| __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ | _afterCACommitHandler | _applyBlockToCFArrayCopiedToStack
| ___afterCACommitHandler_block_invoke | __38-[UITableView touchesEnded:withEvent:]_block_invoke |
-[UITableView _userSelectRowAtPendingSelectionIndexPath:] | -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] | -[MessageListViewController tableView:didSelectRowAtIndexPath:] | _objc_rootAlloc | class_createInstance | calloc | malloc_zone_calloc
-[MessageListViewController tableView:didSelectRowAtIndexPath:] 這個就是錯誤的位置