You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Foundation Predicate is available in the open source Foundation. I think it requires iOS 17+ because it uses variadic generics. But that's not actually necessary for the SwiftData APIs which only pass in a single model type.
This should probably go into an own package.
The text was updated successfully, but these errors were encountered:
I've been playing around with Predicates + ManagedModels but always run into a dead-end seemingly because Model properties aren't exposed to the underlying Objective-C runtime so code like this doesn't work:
@ModelfinalclassMyModel:NSManagedObject{varenabled:Boolconvenienceinit(){self.enabled = false
}}// the following works if MyModel is created using the traditional NSManagedObject / @NSManaged meansletp= #Predicate<MyModel>{ $0.enabled == true }letpredicate=NSPredicate(p)// returns nil, because apparently MyModel.enabled isn't bridged
Likewise a simple NSExpression(forKeyPath: \MyModel.enabled) fails with "Foundation/NSObject.swift:132: Fatal error: Could not extract a String from KeyPath \MyModel.enabled"
The same issue breaks interoperability with packages like PredicateKit which relies on being able to convert AnyKeyPath to String using ObjC bridging internals.
I haven't seen a Predicate back port yet, but that seems unrelated to your issue (and this becomes less necessary as time goes by). I've created #36 for this.
The Foundation
Predicate
is available in the open source Foundation. I think it requires iOS 17+ because it uses variadic generics. But that's not actually necessary for the SwiftData APIs which only pass in a single model type.This should probably go into an own package.
The text was updated successfully, but these errors were encountered: