纯属个人总结
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:] 这个就是错误的位置