WWDC24 SALE: Save 50% on all my Swift books and bundles! >>

SOLVED: Day 58 Part 1

Forums > 100 Days of SwiftUI

When I run the app, after pressing the Add Example button, the app crashes with:

Thread 1: "An NSManagedObject of class 'Ship' must have a valid NSEntityDescription."

I initially after Day 57, deleted the wizard entity and the and the other one as each of the lessons seemed to have you create a new entity (even though there one was already). So i thought ok, something is correct, I did a clean build folder... that didnt help...deleted the app on the simulator, that didnt help... closed Xcode and the simulator and that didnt help. So I deleted the entire CoreDataProjectApp and made a new one...

I still have the issue....

I also made sure the NSPersistentContainer name matches the name of my CoreDataProject.xcdatamodeid

what am I missing?

import CoreData
import Foundation

class DataController: ObservableObject {
  let container = NSPersistentContainer(name: "CoreDataProject")

  init() {
      container.loadPersistentStores { description, error in
          if let error = error {
              print("Core Data failed to load: \(error.localizedDescription)")


Save 50% in my WWDC sale.

SAVE 50% To celebrate WWDC24, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

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.