Skip to content

Commit 3aa62e6

Browse files
Move collection view cleanup to didMoveToWindow for earlier teardown
The removeFromSuperview in deinit fires too late — the ListView may still be retained while KIF traverses the view hierarchy during test teardown. Moving cleanup to didMoveToWindow(nil) detaches the collection view as soon as the ListView leaves the window, preventing UICollectionViewData from accessing a corrupted weak reference during layout.
1 parent e2d6b77 commit 3aa62e6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

ListableUI/Sources/ListView/ListView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,9 +1113,13 @@ public final class ListView : UIView
11131113
public override func didMoveToWindow()
11141114
{
11151115
super.didMoveToWindow()
1116-
1116+
11171117
if self.window != nil {
11181118
self.updateScrollViewInsets()
1119+
} else {
1120+
self.collectionView.delegate = nil
1121+
self.collectionView.dataSource = nil
1122+
self.collectionView.removeFromSuperview()
11191123
}
11201124
}
11211125

0 commit comments

Comments
 (0)