TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

App runs fine, but SwiftUI preview complains “executeFetchRequest:error: A fetch request must have an entity..”

Forums > SwiftUI

I'm migrating my app from Obj-C to Swift. It uses Core Data, and most of the entities are implemented in Obj-C. I just took a stab at converting one of my views to SwiftUI, and it runs correctly, but Preview crashes with

“executeFetchRequest:error: A fetch request must have an entity..”

I've tried declaring the fetch request both with and without the entity: argument:

@FetchRequest(entity: NewsItem.entity(), sortDescriptors: [])   var newsItems : FetchedResults<NewsItem>

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.