Cannot convert value of type 'PredicateExpressions.Equal<PredicateExpressions.KeyPath<PredicateExpressions.Variable<Quote>, UUID>, PredicateExpressions.KeyPath<PredicateExpressions.Value<Quote>, UUID>>' to closure result type 'any StandardPredicateExpression<Bool>'

에러가 발생하였습니다. 

 

문제가 발생한 이유는 Predicate 내부에서 다른 모델 객체를 참조하는 것은 불가능하기 때문입니다.

위에 코드에서는 quote.id 를 통해서 quote 모델 객체의 id 를 참조하고 있으므로 문제가 발생합니다.

predicate: #Predicate { $0.id == quote.id }

 

그렇기 때문에 단순히 Predicate 외부에 참조할 객체의 변수를 담아 다음과 같이 문제를 해결할 수 있습니다.

 

 

 

As read here, you cannot reference a model object inside of a Predicate. So if you wanted to filter for a Usermodel, you could by using its id outside of the Predicate like such:

ytw_developer