如何找到坠机线?

时间:2014-05-02 08:55:26

标签: ios xcode

我使用xCode时遇到了一些初学者问题。每次应用程序崩溃时我都发现很难找到问题,因为我不理解当前的日志我似乎有一个数组的问题。我认为这是一个数组,我删除了它所在的类。

我想知道如何阅读此日志:

2014-05-02 10:49:32.808 myCompany[2793:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
    0   CoreFoundation                      0x017f21e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x015718e5 objc_exception_throw + 44
    2   CoreFoundation                      0x017a4abc -[__NSArrayM insertObject:atIndex:] + 844
    3   CoreFoundation                      0x017a4760 -[__NSArrayM addObject:] + 64
    4   UIKit                               0x00794a4b PushNextClassForSettingIMP + 383
    5   UIKit                               0x00794838 __workaround10030904InvokeWithTarget_block_invoke + 29
    6   UIKit                               0x00284413 +[UIView _performCustomizableAppearanceModifications:] + 26
    7   UIKit                               0x00794810 workaround10030904InvokeWithTarget + 940
    8   UIKit                               0x0078ee71 +[_UIAppearance _applyInvocationsTo:window:matchingSelector:] + 3779
    9   UIKit                               0x0078f633 +[_UIAppearance _applyInvocationsTo:window:] + 55
    10  UIKit                               0x0029b5a3 -[UIView(Internal) _applyAppearanceInvocations] + 270
    11  UIKit                               0x0029c002 __88-[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:]_block_invoke + 65
    12  UIKit                               0x0029bf8f -[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:] + 204
    13  UIKit                               0x0029bebe -[UIView(Internal) _didChangeFromIdiom:onScreen:traverseHierarchy:] + 52
    14  UIKit                               0x003f44b7 -[UILabel(_UIAccessibilityButtonShapesSupportInternal) _didChangeFromIdiom:onScreen:traverseHierarchy:] + 73
    15  UIKit                               0x004ed776 -[UITabBarButtonLabel _didChangeFromIdiom:onScreen:traverseHierarchy:] + 73
    16  UIKit                               0x0029be82 -[UIView(Internal) _didChangeFromIdiomOnScreen:traverseHierarchy:] + 172
    17  UIKit                               0x0029b466 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1624
    18  UIKit                               0x0029b109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
    19  UIKit                               0x00334458 -[UIControl _didMoveFromWindow:toWindow:] + 65
    20  UIKit                               0x0029b109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
    21  UIKit                               0x004fad59 -[UITabBar(UITabBarPrivate) _didMoveFromWindow:toWindow:] + 65
    22  UIKit                               0x0029b109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
    23  UIKit                               0x0029296f __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 158
    24  UIKit                               0x002927fb -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
    25  UIKit                               0x0029ddd4 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1875
    26  UIKit                               0x00290dba -[UIView(Hierarchy) addSubview:] + 56
    27  UIKit                               0x00270406 -[UIWindow addRootViewControllerViewIfPossible] + 481
    28  UIKit                               0x002705ef -[UIWindow _setHidden:forced:] + 312
    29  UIKit                               0x0027086b -[UIWindow _orderFrontWithoutMakingKey] + 49
    30  UIKit                               0x0027b3c8 -[UIWindow makeKeyAndVisible] + 65
    31  UIKit                               0x0022bbc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
    32  UIKit                               0x00230667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
    33  UIKit                               0x00244f92 -[UIApplication handleEvent:withNewEvent:] + 3517
    34  UIKit                               0x00245555 -[UIApplication sendEvent:] + 85
    35  UIKit                               0x00232250 _UIApplicationHandleEvent + 683
    36  GraphicsServices                    0x037e7f02 _PurpleEventCallback + 776
    37  GraphicsServices                    0x037e7a0d PurpleEventCallback + 46
    38  CoreFoundation                      0x0176dca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    39  CoreFoundation                      0x0176d9db __CFRunLoopDoSource1 + 523
    40  CoreFoundation                      0x0179868c __CFRunLoopRun + 2156
    41  CoreFoundation                      0x017979d3 CFRunLoopRunSpecific + 467
    42  CoreFoundation                      0x017977eb CFRunLoopRunInMode + 123
    43  UIKit                               0x0022fd9c -[UIApplication _run] + 840
    44  UIKit                               0x00231f9b UIApplicationMain + 1225
    45  myCompany                                 0x000043fd main + 141
    46  libdyld.dylib                       0x01e39701 start + 1
)

编辑:

this caused the problem :

UIImage *tabBackground = [[UIImage imageNamed:@"image.PNG"]
                          resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UITabBarItem appearance] setImage:tabBackground];

我仍然不明白为什么它不能只显示像android这样的错误行。我通过评论衬里找到了这个

1 个答案:

答案 0 :(得分:0)

我认为你必须跟进本教程,明确提到这个

http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1

根据您的日志详情,

  1. 您正在尝试使用nil对象创建数组。

  2. 尝试将nil对象插入数组

  3. 以上两种情况都会导致应用程序崩溃。

    启用僵尸

    产品 - >编辑方案 - >诊断 - >单击“启用僵尸对象”

    您忘了在数组创建的最后一个索引处添加nil。

    像这样

    NSArray *array = [NSArray arrayWithObjects:@"1",@"2"]; 
    

    但它应该是

    NSArray *array = [NSArray arrayWithObjects:@"1",@"2",nil]; 
    

    但是如果你正在使用NSMutableArray并添加对象,那么你应该有效,如下所示。

           if (myObjectToBeAddedToArray!=nil) {
    
            [arrayMutable addObject:myObjectToBeAddedToArray];
    
           }