简体   繁体   English

以未捕获的 NSException Xcode 类型异常终止

[英]Terminating with uncaught exception of type NSException Xcode

I have a problem when I follow this tutorial.我在学习教程时遇到了问题。 It doesn't work.它不起作用。 Can anyone help me fix this error?谁能帮我解决这个错误? This tutorial uses Swift 4, iOS 11, and Xcode 9 but I used iOS 12 and Xcode 10.1.本教程使用 Swift 4、iOS 11 和 Xcode 9,但我使用的是 iOS 12 和 Xcode 10.1。 Did that cause the problem?这是否导致了问题? Because I just followed the tutorial correctly.因为我刚刚正确地遵循了教程。

Here is the error message:这是错误消息:

2019-03-09 22:27:39.775603+0700 Ratings[667:8658] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
2019-03-09 22:27:40.020185+0700 Ratings[667:8658] *** Assertion failure in -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3698.93.8/UITableView.m:8054
2019-03-09 22:27:40.062689+0700 Ratings[667:8658] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier PlayerCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010ed561bb __exceptionPreprocess + 331
    1   libobjc.A.dylib                     0x000000010d399735 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010ed55f42 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x000000010cd9c877 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
    4   UIKitCore                           0x00000001119ec5b1 -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] + 868
    5   UIKitCore                           0x00000001119ec219 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 91
    6   Ratings                             0x000000010ca6f950 $S7Ratings21PlayersViewControllerC05tableC0_12cellForRowAtSo07UITableC4CellCSo0jC0C_10Foundation9IndexPathVtF + 240
    7   Ratings                             0x000000010ca6fd9c $S7Ratings21PlayersViewControllerC05tableC0_12cellForRowAtSo07UITableC4CellCSo0jC0C_10Foundation9IndexPathVtFTo + 108
    8   UIKitCore                           0x0000000111a0766e -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 771
    9   UIKitCore                           0x0000000111a07bfb -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 73
    10  UIKitCore                           0x00000001119cec36 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2863
    11  UIKitCore                           0x00000001119ef8ee -[UITableView layoutSubviews] + 165
    12  UIKitCore                           0x0000000111cad795 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1441
    13  QuartzCore                          0x0000000113235b19 -[CALayer layoutSublayers] + 175
    14  QuartzCore                          0x000000011323a9d3 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
    15  QuartzCore                          0x00000001131b37ca _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 342
    16  QuartzCore                          0x00000001131ea97e _ZN2CA11Transaction6commitEv + 576
    17  UIKitCore                           0x00000001117de2d0 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 139
    18  CoreFoundation                      0x000000010ecbb62c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    19  CoreFoundation                      0x000000010ecbade0 __CFRunLoopDoBlocks + 336
    20  CoreFoundation                      0x000000010ecb5654 __CFRunLoopRun + 1284
    21  CoreFoundation                      0x000000010ecb4e11 CFRunLoopRunSpecific + 625
    22  GraphicsServices                    0x0000000116f541dd GSEventRunModal + 62
    23  UIKitCore                           0x00000001117c381d UIApplicationMain + 140
    24  Ratings                             0x000000010ca6e547 main + 71
    25  libdyld.dylib                       0x00000001102d0575 start + 1
    26  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

You can find my source code on my github repo here .你可以找到我的源代码在我的GitHub库 在这里

You defined cell identifier as PlayersCell in storyboard.您在情节PlayersCell中将单元标识符定义为PlayersCell change it to PlayerCell将其更改为PlayerCell

Please read the error message carefully.请仔细阅读错误信息。 The most significant parts are最重要的部分是

unable to dequeue a cell with identifier PlayerCell无法将带有标识符 PlayerCell 的单元格出列

and the line before the NSAssertionHandler handleFailureInMethod line which indicates where the error occurs:以及NSAssertionHandler handleFailureInMethod之前的行,指示错误发生的位置:

0x00000001119ec5b1 -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] + 868 0x00000001119ec5b1 -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] + 868

It means that the reuse identifier of the table view cell in Interface Builder is not set or doesn't match the identifier specified in cellForRow in your case a simple typo.这意味着 Interface Builder 中表视图单元格的重用标识符未设置或与cellForRow中指定的标识符不匹配,这是一个简单的错字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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