Skip to content

Commit b7be8db

Browse files
authored
Merge pull request #5 from cthieba3-ford/fix-crash-related-to-main-thread-scheduling
Prevent crashes due to main thread scheduling issues reloading UITableView
2 parents b75664c + 5804777 commit b7be8db

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Presentables/Classes/Table views/Presentables+UITableView.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ fileprivate extension Array where Element == UITableViewCell.Type {
2121
extension UITableView: PresentableCollectionElement {
2222

2323
func safeReloadData() {
24-
DispatchQueue.main.async {
25-
self.reloadData()
24+
if Thread.isMainThread {
25+
reloadData()
26+
} else {
27+
DispatchQueue.main.async {
28+
self.reloadData()
29+
}
2630
}
2731
}
2832

0 commit comments

Comments
 (0)