Hi, i did try using both method 1 & method 2 still giving me crashes (please refer to the bottom for the crash report). Please do let me know where I need to correct it. Thank you very much in advance!
Method 1
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? SearchCell else {
return UITableViewCell()
}
if wordLists.count != 0 {
let currentRow = wordLists[indexPath.row]
cell.resultLabel.text = currentRow
}
return cell
} //Line 1700
Method 2
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! SearchCell
if wordLists.count != 0 {
let currentRow = wordLists[indexPath.row]
cell.resultLabel.text = currentRow
}
return cell
}
Crash report from Fabric
Crashed: com.apple.main-thread
0 MyApp 0x1005e0810 specialized SearchVC.tableView(UITableView, cellForRowAt : IndexPath) -> UITableViewCell (SearchVC.swift:1700)
1 MyApp 0x1005d3534 @objc SearchVC.tableView(UITableView, cellForRowAt : IndexPath) -> UITableViewCell (SearchVC.swift)
2 UIKit 0x18cd540cc -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 668
3 UIKit 0x18cd53d84 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80
4 UIKit 0x18cd52aa0 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2280
5 UIKit 0x18cd4e5ec -[UITableView layoutSubviews] + 140
6 UIKit 0x18cc8b6f4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1420
7 QuartzCore 0x187201fec -[CALayer layoutSublayers] + 184
8 QuartzCore 0x18720617c CA::Layer::layout_if_needed(CA::Transaction*) + 324
9 QuartzCore 0x187172830 CA::Context::commit_transaction(CA::Transaction*) + 320
10 QuartzCore 0x18719a364 CA::Transaction::commit() + 580
11 UIKit 0x18d064518 _UIApplicationFlushRunLoopCATransactionIfTooLate + 172
12 UIKit 0x18d6415d0 __handleEventQueueInternal + 5520
13 UIKit 0x18d63a368 __handleHIDEventFetcherDrain + 152
14 CoreFoundation 0x183023404 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
15 CoreFoundation 0x183022ce0 __CFRunLoopDoSources0 + 456
16 CoreFoundation 0x18302079c __CFRunLoopRun + 1204
17 CoreFoundation 0x182f40da8 CFRunLoopRunSpecific + 552
18 GraphicsServices 0x184f25020 GSEventRunModal + 100
19 UIKit 0x18cf5d758 UIApplicationMain + 236
20 MyApp 0x1005a7af4 main (History+CoreDataProperties.swift:16)
21 libdyld.dylib 0x1829d1fc0 start + 4