diff --git a/AltStore/Types/Managed.swift b/AltStore/Types/Managed.swift index 425032f8..7d4a48a2 100644 --- a/AltStore/Types/Managed.swift +++ b/AltStore/Types/Managed.swift @@ -50,4 +50,18 @@ struct Managed return result } + + // Optionals + subscript(dynamicMember keyPath: KeyPath) -> T? where ManagedObject == Optional { + var result: T? + + if let context = self.managedObjectContext { + context.performAndWait { + result = self.wrappedValue?[keyPath: keyPath] as? T + } + } else { + result = self.wrappedValue?[keyPath: keyPath] as? T + } + return result + } }