Skip to content

Commit 88e36eb

Browse files
Copilotjanusw
andcommitted
Use FirstOrDefault to prevent InvalidOperationException
Co-authored-by: janusw <484108+janusw@users.noreply.github.com>
1 parent 1800fe4 commit 88e36eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Camera.MAUI/Apple/MauiCameraView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,9 @@ private void UpdateTransform()
684684
{
685685
UIWindowScene windowScene = null;
686686
if (OperatingSystem.IsIOSVersionAtLeast(15))
687-
windowScene = UIApplication.SharedApplication.ConnectedScenes.ToArray().First(s => s is UIWindowScene) as UIWindowScene;
687+
windowScene = UIApplication.SharedApplication.ConnectedScenes.ToArray().FirstOrDefault(s => s is UIWindowScene) as UIWindowScene;
688688
else
689-
windowScene = UIApplication.SharedApplication.Windows.First().WindowScene;
689+
windowScene = UIApplication.SharedApplication.Windows.FirstOrDefault()?.WindowScene;
690690

691691
if (windowScene != null)
692692
{

0 commit comments

Comments
 (0)