应用程序崩溃:iOS 8中的NSInvalidArgumentException

时间:2014-09-17 06:10:40

标签: ios objective-c iphone xcode ios8

我在一家公司工作,我们正在iOS上做一些应用程序。我们的应用程序很好用iOS 7.但我尝试了XCode模拟器iphone 6或onether。程序是错误的。我在下面分享......

2014-09-17 08:57:59.972 [783:12416] registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.
2014-09-17 08:57:59.976 [783:12416] Attempting to badge the application icon but haven't received permission from the user to badge the application
2014-09-17 08:58:00.067 [783:12416] -[NSArrayI numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x7f9250fa9e00
2014-09-17 08:58:00.085 [783:12416] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x7f9250fa9e00'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010f4903f5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010d74dbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010f49750d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010f3ef7fc ___forwarding_ + 988
    4   CoreFoundation                      0x000000010f3ef398 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x000000010bc9790e -[UITableViewRowData _updateNumSections] + 84
    6   UIKit                               0x000000010bc98304 -[UITableViewRowData invalidateAllSections] + 69
    7   UIKit                               0x000000010baee343 -[UITableView _updateRowData] + 214
    8   UIKit                               0x000000010bb03107 -[UITableView noteNumberOfRowsChanged] + 112
    9   UIKit                               0x000000010bb0285d -[UITableView reloadData] + 1316
    10  UIKit                               0x000000010bb0b5a6 -[UITableView layoutSubviews] + 31
    11  UIKit                               0x000000010ba98199 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
    12  QuartzCore                          0x000000010b6c7f98 -[CALayer layoutSublayers] + 150
    13  QuartzCore                          0x000000010b6bcbbe _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    14  QuartzCore                          0x000000010b6bca2e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    15  QuartzCore                          0x000000010b62aade _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
    16  QuartzCore                          0x000000010b62bbea _ZN2CA11Transaction6commitEv + 390
    17  UIKit                               0x000000010ba1d67d -[UIApplication _reportMainSceneUpdateFinished:] + 44
    18  UIKit                               0x000000010ba1e368 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2642
    19  UIKit                               0x000000010ba1cd22 -[UIApplication workspaceDidEndTransaction:] + 179
    20  FrontBoardServices                  0x0000000114aaa2a3 31-[FBSSerialQueue performAsync:]_block_invoke + 16
    21  CoreFoundation                      0x000000010f3c5abc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 12
    22  CoreFoundation                      0x000000010f3bb805 __CFRunLoopDoBlocks + 341
    23  CoreFoundation                      0x000000010f3bb5c5 __CFRunLoopRun + 2389
    24  CoreFoundation                      0x000000010f3baa06 CFRunLoopRunSpecific + 470
    25  UIKit                               0x000000010ba1c799 -[UIApplication _run] + 413
    26  UIKit                               0x000000010ba1f550 UIApplicationMain + 1282
    27  Polatlı Mersin Borsası            0x000000010ab89813 main + 115
    28  libdyld.dylib                       0x000000010ddcc145 start + 1
    29  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

3 个答案:

答案 0 :(得分:0)

As per Apple documentation registerForRemoteNotificationTypes:在iOS 8中已弃用,您可以使用registerForRemoteNotificationsregisterUserNotificationSettings

答案 1 :(得分:0)

罪魁祸首可以在顶部的第三行看到

2014-09-17 08:58:00.067 [783:12416] -[NSArrayI numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x7f9250fa9e00
2014-09-17 08:58:00.085 [783:12416] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x7f9250fa9e00'

首先在代码中放置一个异常断点 enter image description here

然后再次运行代码并查看引发异常的行。在你的情况下,由于在NSArray对象上调用了numberOfSectionsInTableView(这是一个tableView委托方法),似乎存在一些问题。

尝试使用异常断点并进行调试并查看。 干杯。玩得开心

答案 2 :(得分:0)

您的视图控制器必须符合此协议UITableViewDataSource:有两种方法是@required,您需要在代码中实现这些方法:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

但也有其他方法。您必须实施numberOfSectionsInTableView:

看一下delegate& datasource与所有情节提要中的viewcontrollerviewcontroller .m类

相关联

如果这还不是问题。尝试使用断点并调试问题......