How to read crash log? How to find why the app crashes in system library? What means EXC_CRASH (SIGABRT)?

烈酒焚心 提交于 2019-11-29 07:10:59
makdad

First, you need to symbolicate the crash log using the DSYM to understand what's happening. You'll need to have the DSYM file from the time that the application was built. The DSYM file allows you to reverse map from those memory addresses back to readable lines of code.

SIGABRT is the signal that you get when you have an unhandled exception, such as calling [someArray objectAtIndex:2] if the array only had 1 item. Or, more often, an unrecognized selector: [NSArray unsignedIntValue].

Take a look at this crash log in this question. Note that the call stack libraries in Foundation are the same as your code - and it's an unrecognized selector.

Your code is:

NSNumber *num = foo;
if (num)
{
  bar = [num unsignedIntValue];
}

What you haven't told us -- but is very important -- is what is in "foo". How do you assign that NSNumber? If it is any other object than an NSNumber, then your crash log will look like yours.

If you wanted to be REALLY defensive in your programming, you can say:

if (num && [num isKindOfClass:[NSNumber class]])

But really, whatever your "foo" is should always be returning an NSNumber.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!