简体   繁体   中英

App crash: NSInvalidArgumentException in iOS 8

I am working a company, and we are doing some application in iOS. Our application good work iOS 7. But I tried XCode simulator iphone 6 or onether. program was give error. I am sharing at below...

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

按照苹果的文档 registerForRemoteNotificationTypes :在iOS的8已被弃用,而不是你可以使用registerForRemoteNotificationsregisterUserNotificationSettings

The culprit can be seen in the third line from top

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'

Put an exception breakpoint in your code first
在此处输入图片说明

Then again run the code and see in which line your exception is getting raised. In your case there seems to be some issue due to which numberOfSectionsInTableView (which is a tableView delegate method) is getting called on an NSArray object.

Try with the exception breakpoint and debug and see. Cheers. Have fun

Your view controller must conform to this protocol UITableViewDataSource : there are two methods witch are @required and these you need to implement in your code:

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

But there are other methods too. You have to implement numberOfSectionsInTableView:

Take a look if delegate & datasource are linked to viewcontroller in all storyboards or viewcontroller .m class

If this is still not the problem. Try with breakpoints and debug the problem...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM