fix: Check array bounds to avoid crash

This commit is contained in:
Andrea Busi
2025-05-15 10:31:41 +02:00
parent 9bf6b75dac
commit 6d4c1eb979
@@ -628,9 +628,15 @@ class SeismicNetworksViewController: UIViewController, UITableViewDelegate, UITa
if let centerIndexPath = getCenterCellIndexPath(), centerIndexPath != currentCenteredIndexPath {
currentCenteredIndexPath = centerIndexPath
let row = rows[centerIndexPath.row]
if case .seismic = row, seismicViewModels.count > centerIndexPath.row {
scrollIndicatorView.highlighted = seismicViewModels[centerIndexPath.row]
if rows.count > centerIndexPath.row {
let row = rows[centerIndexPath.row]
if case .seismic = row, seismicViewModels.count > centerIndexPath.row {
scrollIndicatorView.highlighted = seismicViewModels[centerIndexPath.row]
} else {
scrollIndicatorView.highlighted = nil
}
} else {
scrollIndicatorView.highlighted = nil
}
}
}