mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-17 18:53:40 +01:00
Supports optional @Managed properties
This commit is contained in:
@@ -50,4 +50,18 @@ struct Managed<ManagedObject>
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optionals
|
||||||
|
subscript<Wrapped, T>(dynamicMember keyPath: KeyPath<Wrapped, T>) -> T? where ManagedObject == Optional<Wrapped> {
|
||||||
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user