From 7598948bcc301f1597edb955aafa41d7e0e355c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=87=E4=BC=98?= Date: Wed, 5 Aug 2020 17:02:31 +0800 Subject: [PATCH] fixed iOS14 beta4 crash --- Source/ExtendCustomModelType.swift | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/ExtendCustomModelType.swift b/Source/ExtendCustomModelType.swift index fbe7289..725af03 100644 --- a/Source/ExtendCustomModelType.swift +++ b/Source/ExtendCustomModelType.swift @@ -74,14 +74,20 @@ fileprivate func assignProperty(convertedValue: Any, instance: _ExtendCustomMode fileprivate func readAllChildrenFrom(mirror: Mirror) -> [(String, Any)] { var children = [(label: String?, value: Any)]() - let mirrorChildrenCollection = AnyRandomAccessCollection(mirror.children)! - children += mirrorChildrenCollection + if let mirrorChildrenCollection = AnyRandomAccessCollection(mirror.children) { + children += mirrorChildrenCollection + } var currentMirror = mirror while let superclassChildren = currentMirror.superclassMirror?.children { - let randomCollection = AnyRandomAccessCollection(superclassChildren)! - children += randomCollection - currentMirror = currentMirror.superclassMirror! + if let randomCollection = AnyRandomAccessCollection(superclassChildren) { + children += randomCollection + } + if let superclassMirror = currentMirror.superclassMirror { + currentMirror = superclassMirror + } else { + break + } } var result = [(String, Any)]() children.forEach { (child) in