我正在try 用新的#Predicate宏获得一些结果.当我try 在谓词中使用enum
属性时,问题出现了.有没有人知道这是不是可以做到的,或者这是不是一个漏洞?
XCode 15 beta 4个
获取1:
let predicate = #Predicate<ModelA> { $0.type == ModelA.ModelAType.a }
Fetch 2:
let predicate = #Predicate<ModelA> { $0.type.rawValue == ModelA.ModelAType.a.rawValue }
模型:
@Model final class ModelA: Codable {
@Attribute(.unique) var id: Int64 = 0
enum ModelAType: Int, CaseIterable, Codable { case a = 1, b }
var type: ModelAType = ModelAType.a
}
错误:
Type 'ModelA.Type' cannot conform to 'StandardPredicateExpression'
Type 'ModelA.Type' cannot conform to 'PredicateExpression'
Cannot infer key path type from context; consider explicitly specifying a root type