If Codegen is set to "Class Definition" then you can just import your entity's NSManagedObject
subclass header file.
Import:
#import "Tag+CoreDataClass.h"
Then the creation of your Tag
object will be recognized.
Tag *tag = [NSEntityDescription insertNewObjectForEntityForName:@"Tag" inManagedObjectContext:[self managedObjectContext];
tag.name = @"Tag Name";
Note: If you want to see the files that were generated on your behalf, you can check the DerivedData folder for your project. You should not edit these files or import them into your project.
Something like:
/Users/{Username}/Library/Developer/Xcode/DerivedData/{Your Project Name}/Build/Intermediates/{Your Project Name}.build/Debug-iphonesimulator/{Your Project Name}.build/DerivedSources/CoreDataGenerated/{Your Project Name}/
There are other Codegen options that offer different options depending on your use case:
- None/Manual: Allows you to manage the
NSManagedObject
subclasses yourself. With this option, you will see the files in your project and you can modify them.
- Category/Extension: Allows you to have custom properties (attributes) that you do not want Core Data to manage.
I posted a more detailed answer regarding Codegen options here: https://stackoverflow.com/a/40647786/4748172