7
let startDate: Date = Date()
    let predicate = #Predicate<Trip> { session in
        session.startTime >= startDate
    }

Does anybody has this issue when #Predicate do not work on Date? I am getting unsupported predicate error. Any ideas to fix?

1

1 Answer 1

3

Since date isn't yet available to be used on the #Predicate macro, in the meantime, the following workaround can be used:

@Query private var queriedTrips: [Trip]

// Create a computed property
var trips: [Trip] {
    let startDate: Date = Date()

    return queriedTrips.filter({ $0.startTime >= startDate })
}

While this may not be ideal, I don't think there's much we can do at the moment.

Sign up to request clarification or add additional context in comments.

1 Comment

Date isn't yet available to be used on the #Predicate macro . plz provide any documentation link to support it ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.