iOS App崩溃了

时间:2011-07-24 15:10:01

标签: objective-c ios crash

我正在为iOS设备编写静态库。使用xcode 3.2.6,选择最新的iOS 4.3进行编译,并选择iOS 3.1.2进行部署。保持所有设置默认,Library正在使用多个框架,如安全性。     为了测试,我首先将此lib作为应用程序编写,并仅在int retVal = UIApplicationMain(argc, argv, nil, nil);之前从主文件调用函数。所以这一切都完美无缺。

Now if I added UI components and calling functions as per user select an option, my application starts crashing randomly or aborted abnormally.

Latest crash Log is as follows:



    B61B817A-CB86-4B3D-A2BE-5CAFC9AFC857

    Exception Type:  EXC_BAD_ACCESS (SIGBUS)
    Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000012
    Crashed Thread:  0  Dispatch queue: com.apple.main-thread

    Application Specific Information:
    objc_msgSend() selector name: objectForKey:
    iPhone Simulator 238.2, iPhone OS 4.3 (iPad/8F192)
    iPhone Simulator 238.2, iPhone OS 4.3 (iPad/8F192)


    Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
    0   libobjc.A.dylib                 0x0103109b objc_msgSend + 15
    1   ???                             0x000600b8 OBJC_CLASS_$_MPLogHndlr + 0
    2   iTestApp                    0x0004267a -[Record2 getInfo] + 113 (Record2.m:609)
    3   iTestApp                    0x000434c1 -[Record2 getAllInfo:] + 44 (Record2.m:798)
    4   iTestApp                    0x00016919 -[BasicInfo getInfo] + 70 (BasicInfo.m:238)
    5   iTestApp                    0x000283bf -[AllInfo init:] + 1724 (AllInfo.m:55)
    6   iTestApp                    0x00012130 -[Emp getEmpInfo] + 461 (Emp.m:1175)
    7   iTestApp                    0x00003808 -[iTestApp ViewController btnApiGo_Clicked:] + 2155 (iTestApp ViewController.m:274)
    8   UIKit                           0x0032f4fd -[UIApplication sendAction:to:from:forEvent:] + 119
    9   UIKit                           0x003bf799 -[UIControl sendAction:to:forEvent:] + 67
    10  UIKit                           0x003c1c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    11  UIKit                           0x003c07d8 -[UIControl touchesEnded:withEvent:] + 458
    12  UIKit                           0x00353ded -[UIWindow _sendTouchesForEvent:] + 567
    13  UIKit                           0x00334c37 -[UIApplication sendEvent:] + 447
    14  UIKit                           0x00339f2e _UIApplicationHandleEvent + 7576
    15  GraphicsServices                0x01b18992 PurpleEventCallback + 1550
    16  CoreFoundation                  0x00eac944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    17  CoreFoundation                  0x00e0ccf7 __CFRunLoopDoSource1 + 215
    18  CoreFoundation                  0x00e09f83 __CFRunLoopRun + 979
    19  CoreFoundation                  0x00e09840 CFRunLoopRunSpecific + 208
    20  CoreFoundation                  0x00e09761 CFRunLoopRunInMode + 97
    21  GraphicsServices                0x01b171c4 GSEventRunModal + 217
    22  GraphicsServices                0x01b17289 GSEventRun + 115
    23  UIKit                           0x0033dc93 UIApplicationMain + 1160
    24  iTestApp                    0x00001f14 main + 102 (main.m:14)
    25  iTestApp                    0x00001ea5 start + 53

以下是代码:

- (int) getInfo
{
    @try{
        Field   *f = [self gField:F_NAME];
        int index = [self getFIndex:f];

        return [f findValAtIndex:index]; <=== 609 
    }
    @catch (NSException * e) 
    {
        MpDebugTrace(@"Exception : <%@> %@", [e name], [e reason]);
        @throw; // re-throws exception
    }
    return -1;
}


    - (int) findValAtIndex:(int) idx
    {
        NSString *key  = [NSString stringWithFormat:@"%d", idx];

        // vals is NSMutableDictionary
        NSNumber *valForKey = [vals objectForKey:key];
        return  [valForKey intValue];
    }

0 个答案:

没有答案