Sam Sam - 2 months ago 24
Swift Question

Sigabrt error with tableview

I have recently added a UITableView to my app and have receved these errors.

Ive looked everywhere on the internet but am really hoping someone can help me.

DEBUGER-

2016-10-08 02:34:41.404 SharkMate[15408:428153] Configuring the default app.
2016-10-08 02:34:41.440: FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-10-08 02:34:41.442 SharkMate[15408:] Firebase Analytics v.3402000 started
2016-10-08 02:34:41.476 SharkMate[15408:] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2016-10-08 02:34:41.502 SharkMate[15408:] Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
2016-10-08 02:34:41.551 SharkMate[15408:] Firebase Analytics enabled
2016-10-08 02:34:41.575 SharkMate[15408:428153] * Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UITableView.m:7971
2016-10-08 02:34:41.579 SharkMate[15408:428153] *
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView (; layer = ; contentOffset: {0, -64}; contentSize: {414, 308}>) failed to obtain a cell from its dataSource ()'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f8bcd85 exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001119f1deb objc_exception_throw + 48
2 CoreFoundation 0x000000010f8bcbea +[NSException raise:format:arguments:] + 106
3 Foundation 0x000000010fd91d5a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 UIKit 0x000000011058f4b1 -[UITableView _configureCellForDisplay:forIndexPath:] + 225
5 UIKit 0x000000011059b51e -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 808
6 UIKit 0x000000011059b62c -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
7 UIKit 0x000000011056fd4f -[UITableView _updateVisibleCellsNow:isRecursive:] + 2996
8 UIKit 0x00000001105a4686 -[UITableView _performWithCachedTraitCollection:] + 92
9 UIKit 0x000000011058b344 -[UITableView layoutSubviews] + 224
10 UIKit 0x00000001104f8980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
11 QuartzCore 0x0000000115599c00 -[CALayer layoutSublayers] + 146
12 QuartzCore 0x000000011558e08e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
13 QuartzCore 0x000000011558df0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
14 QuartzCore 0x00000001155823c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
15 QuartzCore 0x00000001155b0086 _ZN2CA11Transaction6commitEv + 486
16 QuartzCore 0x00000001155b07f8 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
17 CoreFoundation 0x000000010f7e1c37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION
+ 23
18 CoreFoundation 0x000000010f7e1ba7 __CFRunLoopDoObservers + 391
19 CoreFoundation 0x000000010f7d711c CFRunLoopRunSpecific + 524
20 UIKit 0x0000000110438f21 -[UIApplication _run] + 402
21 UIKit 0x000000011043df09 UIApplicationMain + 171
22 SharkMate 0x000000010dde9962 main + 114
23 libdyld.dylib 0x00000001124c992d start + 1
24 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Answer

The error signal greatly to tableview not having a cell registered

Register a cell to tableview as below

self.tableView.register(UINib.init(nibName: "CustomCellClassName", bundle: Bundle.main), forCellReuseIdentifier:"cell")

Make sure to set cell identifier in nib