如果你的程序崩溃了,而你又恰好没有捕获异常,那么你的控制台可能会输出如下内容:
2013-03-13 13:30:10.186 Picross[43233:1303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate crash]: unrecognized selector sent to instance 0xc04de10'*** First throw call stack:
(0x355b012 0x32ffe7e 0x35e64bd 0x354abbc 0x354a94e 0x3313663 0x12f54 0x3f0153f 0x3f13014 0x3f042e8 0x3f04450 0x926b5e12 0x9269dcca)
libc++abi.dylib: terminate called throwing an exception
你可能会比较困惑到底程序中哪段代码导致的崩溃。直接在First throw call stack中找‘最小’的地址值,然后用lldb来找这个地址值的符号:
im loo -a 0x12f54
这时你会得到相应的调用函数和行号:
Address: Picross[0x00012f54] (Picross.__TEXT.__text + 67540)
Summary: Picross`__57-[AppDelegate application:didFinishLaunchingWithOptions:]_block_invoke112 + 52 at AppDelegate.m:216
Summary: Picross`__57-[AppDelegate application:didFinishLaunchingWithOptions:]_block_invoke112 + 52 at AppDelegate.m:216
通常这里就是代码中产生崩溃的地方
原文:http://fivelakesstudio.blogspot.com/2013/03/cocoa-debugging-tip.html