Is UITableView at the top?Mon Apr 06 2020

This week I needed to determine if a UITableView was at the top. There are ways of checking if it has scrolled to the top using UIScrollViewDelegate described here, but I needed to determine it from viewDidAppear.

The solution was to check the first visible row's IndexPath

guard let row = myTable.indexPathsForVisibleRows?.first else {
    return
}
if (row.section == 0 && row.row == 0) {
    // Top of the UITableView
}

swift