Core Data: Class not found, using default NSManagedObject instead

Discussion in 'iOS Programming' started by moonman239, Dec 20, 2016.

  1. moonman239, Dec 20, 2016
    Last edited: Dec 21, 2016

    moonman239 macrumors 68000

    Mar 27, 2009
    A while ago, I renamed my Core Data managed object subclasses, but changed them all back, so now the class names match their entity names. However, even after deleting and reinstalling, I get this message for one of my entities:

    "CoreData: warning: Unable to load class named 'X' for entity 'Y'. Class not found, using default NSManagedObject instead."

    where X is the name I put in and Y is the actual name.

    I can't find any mention of the old name in my project. Do I need to delete my model and start over?
  2. 1458279, Dec 20, 2016
    Last edited: Dec 20, 2016

    1458279 Suspended


    May 1, 2010
    Are you running on Xcode on the sim or personal test device?

    If so, I had a problem several times with Core Data and it was solved by deleting the app from sim and/or device. If you FULLY remove the app from your sim/device, it gives it a fresh start.

    Give that a quick try and report back.

    Edit: just in case you don't know what I'm talking about, open you sim go to your app press-n-hold until it prompts you to delete. It's odd, but it actually fixes a core data problem.
  3. moonman239 thread starter macrumors 68000

    Mar 27, 2009
    iPad. Did that, didn't work.
  4. 1458279 Suspended


    May 1, 2010
    "Core Data managed object subclasses" << you're talking about the classes that xcode generates for you? So those were renamed then named back and it doesn't work.

    the X is new name and Y is the old name?

    So somehow the Core Data class info for the old stuff is stuck somewhere. IDK where CD stores all it's config stuff.

    It would be interesting to make a new project with CD and search the directory for the name of that class just to see all the places where it's stored. You could then change the name and see where the new name and old name are.

    I don't know how to search inside of files in OSX, IDK if finder will do it or not.

    My guess is that Xcode/Apple/IOS is storing information in some config file somewhere and if that were deleted it would have to regen (or never work again :D).

    What happens if you name it back to the other name?

    Have you tried the 'clean' option? It's up in the menu system of Xcode somewhere.

    Another option is to make a new project, copy over one by one, all the source files and make a new project, see if that flushes out the old settings.
  5. KALLT macrumors 601

    Sep 23, 2008
    Try regenerating the subclasses in the Editor menu, while in the data-model viewer. Also make sure that none of the entities have any mismatched names in the data-model inspector.

Share This Page