NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

Day 58 - Project 12, part 2 *ISSUE*

Forums > SwiftUI

Hi friends!

The CoreDataProject app keeps crashing on me and provides the following error: Thread 1: "An NSManagedObject of class 'Singer' must have a valid NSEntityDescription."

I've done the Googles and can not figure out how to fix this or what exactly is causing it.

Xcode Version 14.0.1 (14A400) iOS 16 target deploy

   

When you look at your data model is there an Entity named Singer there?

   

@Fly0strich,

Yes. It happens when any data model is created. Following along line for line with all topics on Day 57.

   

SOLVED: As it turns out, I left off the .environment section in the @main part of my app. Easy Fix!!!

import SwiftUI

@main struct CoreDataProjectApp: App { @StateObject private var dataController = DataController() var body: some Scene { WindowGroup { ContentView() .environment(.managedObjectContext, dataController.container.viewContext) } } }

   

Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

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.