From c3d62d238e244b455bd699205e97115e6ffdcc4f Mon Sep 17 00:00:00 2001 From: Dominic Go <18517029+dominicstop@users.noreply.github.com> Date: Fri, 7 Apr 2023 03:46:31 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AB=20Update:=20`getPresentedViewContr?= =?UTF-8?q?ollers`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Update `RNIModalManager.getPresentedViewControllers`. --- .../React Native/RNIModal/RNIModalManager.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ios/src_library/React Native/RNIModal/RNIModalManager.swift b/ios/src_library/React Native/RNIModal/RNIModalManager.swift index 78dcdf90..7aca8d54 100644 --- a/ios/src_library/React Native/RNIModal/RNIModalManager.swift +++ b/ios/src_library/React Native/RNIModal/RNIModalManager.swift @@ -147,10 +147,12 @@ public class RNIModalManager { var presentedVCList: [UIViewController] = [rootVC]; // climb the vc hierarchy to find the topmost presented vc - while presentedVCList.last!.presentedViewController != nil { - if let presentedVC = presentedVCList.last!.presentedViewController { - presentedVCList.append(presentedVC); - }; + while true { + guard let topVC = presentedVCList.last, + let presentedVC = topVC.presentedViewController + else { break }; + + presentedVCList.append(presentedVC); }; return presentedVCList;