1

I have an instance of NSEntityDescription that I obtained through the entity() method on the class of an NSManagedObject subclass. I want to get its name, but the type of that property is String? rather than just String

let entityName: String = MyManagedObjectSubclass.entity().name // Error: Must be unwrapped

Under what circumstances would the name be nil? Is it safe to force-unwrap in this context? I have yet to see it return nil, but I'd like to make sure I'm appropriately handling whatever case would cause that to happen

Michael Hulet
  • 3,253
  • 1
  • 16
  • 33
  • 1
    I'd tend to say that's because when you create it, it can be done "property by property". Ie, if you have already a model set and a persistent coordinator, it should be fine. – Larme Aug 25 '23 at 16:36

0 Answers0