Crash in UITableview cellforrow in iOS 15 beta

Hello,

Crash on reload tableview in ios 15.

Crashed: com.apple.main-thread EXC_BREAKPOINT 0x0000000104a37628 keyboard_arrow_up arrow_right 0 GuardsPro ShiftsListViewController.swift - Line 263 ShiftsListViewController.tableView(:cellForRowAt:) + 263 1 GuardsPro - Line 4345689852 @objc ShiftsListViewController.tableView(:cellForRowAt:) + 4345689852 2 UIKitCore -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 1536 3 UIKitCore -[UITableView _updateVisibleCellsForRanges:createIfNecessary:] + 748 4 UIKitCore -[UITableView _updateVisibleCellsNow:] + 1396 5 UIKitCore -[UITableView layoutSubviews] + 456 6 UIKitCore -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2620 7 QuartzCore CA::Layer::layout_if_needed(CA::Transaction*) + 536 8 QuartzCore CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 144 9 QuartzCore CA::Context::commit_transaction(CA::Transaction*, double, double*) + 500 10 QuartzCore CA::Transaction::commit() + 680 11 QuartzCore CA::Transaction::flush_as_runloop_observer(bool) + 100 12 UIKitCore _UIApplicationFlushCATransaction + 76 13 UIKitCore _UIUpdateSequenceRun + 84 14 UIKitCore schedulerStepScheduledMainSection + 144 15 UIKitCore runloopSourceCallback + 60 16 CoreFoundation CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28 17 CoreFoundation __CFRunLoopDoSource0 + 208 18 CoreFoundation __CFRunLoopDoSources0 + 268 19 CoreFoundation __CFRunLoopRun + 820 20 CoreFoundation CFRunLoopRunSpecific + 600 21 GraphicsServices GSEventRunModal + 164 22 UIKitCore -[UIApplication _run] + 1100 23 UIKitCore UIApplicationMain + 2124 24 GuardsPro AppDelegate.swift - Line 21 main + 21

  • It is hard to find the cause of crashes even when properly formatted crash logs given. Can you show the crash log properly formatted and your code?

  • It would be specially important to have the full ShiftsListViewController tableView(:cellForRowAt:) where the crash apparently occurs.

Add a Comment

Replies

Code attachedBelow

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if list.count <= 0 {
            return UITableViewCell()
        }
        guard let shiftListTableViewCell = tableView.dequeueReusableCell(withIdentifier: "ShiftsListTableViewCell") as? ShiftsListTableViewCell else {
            return UITableViewCell()
        }
        
        let shiftListItem = shiftList[indexPath.section]
        
        shiftListTableViewCell.shiftIdTitleLabel.text = String.init(format: "%@ / #%d",shiftListItem.shiftTitle,shiftListItem.shiftId)
        shiftListTableViewCell.dateLabel.text       = shiftListItem.shiftDate
        shiftListTableViewCell.postSitesLabel.text  = shiftListItem.postSitesName
        shiftListTableViewCell.startTimeLabel.text  = shiftListItem.shiftStartHrs
        shiftListTableViewCell.endTimeLabel.text    = shiftListItem.shiftEndHrs
        shiftListTableViewCell.shiftHoursLabel.text = shiftListItem.shiftHours
        
        if shiftType == ShiftType.OPEN_SHIFT {
            shiftListTableViewCell.shiftStatusLabel.isHidden = false
            shiftListTableViewCell.shiftStatusLabel.text = shiftListItem.requestStatus ? "Sent" : "Pending"
            shiftListTableViewCell.shiftStatusLabel.backgroundColor = shiftListItem.requestStatus ? ColorConstant.appGreenColor : ColorConstant.appYellowColor
            shiftListTableViewCell.shiftStatusLabelHeight.constant = AppConstants.IPAD ? 42 : 21
            shiftListTableViewCell.shiftStatusBottomSpace.constant = AppConstants.IPAD ? 26 : 13
        }else{
            shiftListTableViewCell.shiftStatusLabel.isHidden = true
            shiftListTableViewCell.shiftStatusLabelHeight.constant = 0.0
            shiftListTableViewCell.shiftStatusBottomSpace.constant = 0.0
        }
        
        if AppUtils.isEmpty(value:shiftListItem.skillSet) {
            shiftListTableViewCell.skillSetTitleLabelHeight.constant = 0.0
            shiftListTableViewCell.skillSetTitleLabelTopSpace.constant = 0.0
        }
        else{
            shiftListTableViewCell.skillSetTitleLabelHeight.constant = AppConstants.IPAD ? 38.0 : 19.0
            shiftListTableViewCell.skillSetTitleLabelTopSpace.constant = AppConstants.IPAD ? 22.0 : 11.0
            shiftListTableViewCell.skillSetLabel.text = shiftListItem.skillSet
        }
        
        if AppUtils.isEmpty(value:shiftListItem.department) {
            shiftListTableViewCell.departmentTitleLabelHeight.constant = 0.0
            shiftListTableViewCell.departmentTitleLabelTopSpace.constant = 0.0
        }
        else{
            shiftListTableViewCell.departmentTitleLabelHeight.constant = AppConstants.IPAD ? 38.0 : 19.0
            shiftListTableViewCell.departmentTitleLabelTopSpace.constant = AppConstants.IPAD ? 22.0 : 11.0
            shiftListTableViewCell.departmentLabel.text = shiftListItem.department
        }
        
        if (self.shiftType == ShiftType.UNCONFIRMED && isEditingTableView){
            let selectedShiftIndex =  shiftsToConfirm.firstIndex { (s) -> Bool in
                return s.shiftId == shiftListItem.shiftId
            }
            
            if selectedShiftIndex != nil {
                let selectedPostSiteIcon = UIImage.init(named:"postSite_Selected")?.withRenderingMode(.alwaysTemplate)
                shiftListTableViewCell.checkedImageView.image = selectedPostSiteIcon
                shiftListTableViewCell.checkedImageView.tintColor = ColorConstant.appOrangeColor
            }else{
                shiftListTableViewCell.checkedImageView.image = UIImage(named: "postSite_Unselected")
                shiftListTableViewCell.checkedImageView.tintColor = UIColor.lightGray
            }
            
            shiftListTableViewCell.checkedImageWidth.constant = AppConstants.IPAD ? 46 : 23
            shiftListTableViewCell.checkedImageLeading.constant = AppConstants.IPAD ? 24 : 12
            
        }else{
            shiftListTableViewCell.checkedImageWidth.constant = 0
            shiftListTableViewCell.checkedImageLeading.constant = 0
        }
        
        return shiftListTableViewCell
    }