Invalid redeclaration on CoreData classes

前端 未结 2 1305
甜味超标
甜味超标 2020-12-23 01:55

I am working with CoreData, on an entity called \"RoleName\".

The problem is: I click on \"Create NSManagedObject subclass\" from within my model, and so it automati

相关标签:
2条回答
  • 2020-12-23 02:35

    From Apple : Whats new in Core Data

    Xcode automatic subclass generation

    Xcode now supports automatic generation of NSManagedObject subclasses in the modeling tool. In the entity inspector:

    Manual/None is the default, and previous behavior; in this case you should implement your own subclass or use NSManagedObject. Category/Extension generates a class extension in a file named like ClassName+CoreDataGeneratedProperties. You need to declare/implement the main class (if in Obj-C, via a header the extension can import named ClassName.h). Class Definition generates subclass files named like ClassName+CoreDataClass as well as the files generated for Category/Extension.

    The generated files are placed in DerivedData and rebuilt on the first build after the model is saved. They are also indexed by Xcode, so command-clicking on references and fast-opening by filename works.

    You don't need to manually create subclasses for NSManagedObjects.

    I would suggest that you delete the files that you created with NSManagedObjects (Move them to Trash) and go to every entity in the DataModel Inspector under Codegen select : Manual / None and create than the Subclasses.

    0 讨论(0)
  • 2020-12-23 02:59

    This is because Xcode handles all that by itself. I felt it like a bit of trouble as the auto generated classes don't have all my properties.

    So follow these steps to get this as it used to be:

    • Delete what ever classes you already made for core data.
    • Set class.Module as Current Product module

    • Set Class.codegen as Manual/None

    • Now select your entity and create NSmanagedobject subclass

    • You are all set

    0 讨论(0)
提交回复
热议问题