From 7126bdc0ac086351fbeb7cc7f375c3570ca160c5 Mon Sep 17 00:00:00 2001 From: Alex Odawa Date: Thu, 3 Oct 2024 18:11:09 +0200 Subject: [PATCH] removing assert --- Sources/KIF/Additions/UIView-KIFAdditions.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/KIF/Additions/UIView-KIFAdditions.m b/Sources/KIF/Additions/UIView-KIFAdditions.m index 3c2b30d3..b078a54a 100644 --- a/Sources/KIF/Additions/UIView-KIFAdditions.m +++ b/Sources/KIF/Additions/UIView-KIFAdditions.m @@ -380,7 +380,13 @@ - (UIAccessibilityElement *)accessibilityElementMatchingBlock:(BOOL(^)(UIAccessi [collectionView scrollRectToVisible:visibleRect animated:NO]; [collectionView layoutIfNeeded]; UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath]; - NSAssert(cell, @"UICollectionViewCell returned from 'cellForItemAtIndexPath' is unexpectedly nil!"); + int remainingAttempts = 10; + while (!cell && collectionView.window) { + remainingAttempts--; + NSAssert(remainingAttempts > 0, @"UICollectionViewCell returned from 'cellForItemAtIndexPath' is unexpectedly nil!"); + CFRunLoopRunInMode(UIApplicationCurrentRunMode, 0.01, false); + cell = [collectionView cellForItemAtIndexPath:indexPath]; + } UIAccessibilityElement *element = [cell accessibilityElementMatchingBlock:matchBlock notHidden:NO disableScroll:NO]; // Skip this cell if it isn't the one we're looking for