NSManagedObject subclasses duplicate declaration

So, when my data model is ready, I tried to generate subclasses when my data model file is open:

Editor -> Subclassing NSManaged Object

Well, two files are created, one is a class declaration, the other is a property.

However, it was immediately suggested that I reassess the class that already exists. Here are the original generated files: previously generated files

My question is obvious:

  • When were these two files created?
  • What if I want to use these files in my project navigator and, of course, in the same folder as my ViewController?
+1
source share
4 answers

You generate files that Xcode has already created for you, and thus receive duplicate ads.

Find details in this answer .

0
source

Typically, make changes to an existing object in the underlying data model.

Suppose you add a field to an existing entity in the underlying data model, you will need to restore the class for this object to include this field.

When restoring this class, it will be possible to overwrite existing files.

To answer your questions:

  • It was probably created when the previous change to the object was made.
  • Move previously created files to the desktop. Then create new files. See the difference between the two sets of files and take appropriate action. If I am not mistaken, one file will be an extension, and one will be a class file.
+1
source

So the correct answer seems to be those who commented on my question. The original post is here: fooobar.com/questions/1012077 / ....

Remove all created NSManagedObject subclasses from your project, if they exist.

Install Codegento Manual / None in your .xcdatamodel for all objects Clear project. --- This is a key step that is installed by default on Xcode8.

Empty DerivedData folder p>

Restart xcode

Manually subclass NSManagedObject (in the Editor menu)

Make sure these files are added to your project build

If your problem persists, repeat:

Clear project

Empty DerivedData folder p>

Restart xcode

0
source

In your xcdatamodeld you need to change the Entity Codegen class to Manual / None in the Utilities panel before compiling

enter image description here

0
source

Source: https://habr.com/ru/post/1012073/


All Articles