UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Why Using Date.now Inside The New Predicate Macro throws Error

Forums > SwiftUI

SwiftData Starter Project 6/8

Clicking the above link will redirect you to the point where Mr. Paul shows Date.now cannot be used directly inside the predicate but a local variable is allowed. Can someone explain the reason behind this?

        let now = Date.now
        _destinations = Query(
            filter: #Predicate {
                $0.date > now
            },
            sort: sort
        )

2      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.