【问题标题】:UIApplicationMain crashing in xcode [closed]UIApplicationMain在xcode中崩溃[关闭]
【发布时间】:2014-01-07 09:47:49
【问题描述】:

我的应用程序崩溃了

#import <UIKit/UIKit.h>

int main(int argc, char *argv[])
{

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);      //Thread 1:signal SIGABRT
    [pool release];
    return retVal;

    /*
    int retVal = 0;
    @autoreleasepool {
        NSString *classString = NSStringFromClass([gTalkAppDelegate class]);
        @try {
            retVal = UIApplicationMain(argc, argv, nil, classString);
        }
        @catch (NSException *exception) {
            NSLog(@"Exception - %@",[exception description]);
            exit(EXIT_FAILURE);
        }
    }
    return retVal;
    */
}


2014-01-07 15:41:25.881 testproject[28812:70b] -[__NSCFConstantString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x281d184
2014-01-07 15:41:25.973 testproject[28812:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x281d184'
*** First throw call stack:
(
    0   CoreFoundation                      0x026d75e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x01c028b6 objc_exception_throw + 44
    2   CoreFoundation                      0x02774903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x026c790b ___forwarding___ + 1019
    4   CoreFoundation                      0x026c74ee _CF_forwarding_prep_0 + 14
    5   testproject                        0x0000e7cd -[SecondViewController showData] + 1837
    6   testproject                        0x0000829d -[SecondViewController viewDidAppear:] + 1261
    7   UIKit                               0x0087ac48 -[UIViewController _setViewAppearState:isAnimating:] + 497
    8   UIKit                               0x0087b1d7 -[UIViewController __viewDidAppear:] + 146
    9   UIKit                               0x00898fca -[UINavigationController viewDidAppear:] + 191
    10  UIKit                               0x0087ac48 -[UIViewController _setViewAppearState:isAnimating:] + 497
    11  UIKit                               0x0087b1d7 -[UIViewController __viewDidAppear:] + 146
    12  UIKit                               0x008a827b -[UITabBarController viewDidAppear:] + 113
    13  UIKit                               0x0087ac48 -[UIViewController _setViewAppearState:isAnimating:] + 497
    14  UIKit                               0x0087b1d7 -[UIViewController __viewDidAppear:] + 146
    15  UIKit                               0x0087cb9f __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 44
    16  UIKit                               0x0087b56a -[UIViewController _executeAfterAppearanceBlock] + 63
    17  UIKit                               0x007801a9 ___afterCACommitHandler_block_invoke_2 + 33
    18  UIKit                               0x0078012e _applyBlockToCFArrayCopiedToStack + 403
    19  UIKit                               0x0077ff7e _afterCACommitHandler + 568
    20  CoreFoundation                      0x0269f4ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    21  CoreFoundation                      0x0269f41f __CFRunLoopDoObservers + 399
    22  CoreFoundation                      0x0267d344 __CFRunLoopRun + 1076
    23  CoreFoundation                      0x0267cac3 CFRunLoopRunSpecific + 467
    24  CoreFoundation                      0x0267c8db CFRunLoopRunInMode + 123
    25  GraphicsServices                    0x035e09e2 GSEventRunModal + 192
    26  GraphicsServices                    0x035e0809 GSEventRun + 104
    27  UIKit                               0x00763d3b UIApplicationMain + 1225
    28  testproject                        0x0000213d main + 125
    29  testproject                        0x000020b5 start + 53
    30  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

如何解决。

【问题讨论】:

标签: ios iphone objective-c xcode


【解决方案1】:

查看您的堆栈跟踪,您可以看到在viewDidAppear 中您调用了一个名为showData 的方法,这可以从下面的两行中看出。

5   gtalkhotdial   0x0000e7cd -[SecondViewController showData] + 1837
6   gtalkhotdial   0x0000829d -[SecondViewController viewDidAppear:] + 1261

在这个showData 方法中,你调用了一个试图调用-[__NSCFConstantString countByEnumeratingWithState:objects:count:]: 的东西(不幸的是我们不知道是什么),而那个对象是什么,它没有这个方法。要告诉您更多信息,我们需要查看方法 showData 中的内容。但是您的崩溃显然正在那里发生。如果您还有什么想知道的,请分享该方法的实现。

【讨论】:

    【解决方案2】:

    查看您的堆栈跟踪,行

     2   CoreFoundation                      0x02774903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    

    5   gtalkhotdial                        0x0000e7cd -[SecondViewController showData] + 1837
    

    应该能帮到你

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-15
      • 2014-07-06
      • 1970-01-01
      相关资源
      最近更新 更多