I took a break from coding for several months and came back and discovered changes in CoreData using Xcode8 / iOS10 / macOS Sierra.
I'm trying to get a new generation of the NSManagedObject subclass in Objective-C, but there are very few on the Internet. I have a few things that I need to clarify before I start trimming my project and completely messing things up, but firstly, some things that I found shaking that could be useful to others there ...
Where are the things
Automatically generated files live deep in the DerivedData folder. Look at USER-> Library-> Developer-> Xcode-> DerivedData-> ProjectName-lotsOfRandomLetters-> Build, then continue to open folders until you find DerivedSources-> CoreDataGenerated.
Automatically generated files do not appear in the project folder or navigator, although if there is an error in one Xcode, you will see the source for you.
Xcode things generate
There are three configuration modes - manual / no, class definition and category / extension.
When the codegen entity is set to manual / no (which was the old behavior), creating a subclass of NSmanagedObject using Editor-> Create NSManagedObject Subclass generates 4 files inside your project ...
Entity + CoreDataClass.h and Entity + CoreDataClass.m and Entity + CoreDataProperties.h and Entity + CoreDataProperties.m
(previous version of Xcode 7 generated Entity.h, Entity.m, Entity + CoreDataProperties.h and Entity + CoreDataProperties.m)
If a class definition is specified for the codegen object, Xcode automatically generates the same 4 files in the derived data folder, and not in the project. These files are then marked with a comment saying that you are not modifying them.
Xcode generates 2 files if the codegen entities are set to Category / Extension. These files are marked with a comment saying that you are not modifying them. It...
Entity + CoreDataProperties.h and Entity + CoreDataProperties.m
These 2 files expect the Entity.h file to be in the project and will show an error in Xcode if it is missing. This is the time you can see the source for one of these files in Xcode.
What's in these files
The + CoreDataProperties files look the same as those generated by a previous version of Xcode generated files, with one addition. They contain all the attributes / properties for the object / NSmanagedObject and methods for processing objects that have a relationship from one to many or many. The new addition is the method for the fetchRequest subquery for the new fetchRequest NSmanageObject method.
Questions
1) Is class definition now an obvious and better choice for codegen when you do not have additional properties / functionality to add to a subclass of NSManagedObject, since it automatically updates files for you (when you save the project using cmd -s)?
2) The naming of files with + CoreDataClass follows the legend for the category in the class, which implies that there must be a class for this.
Do I believe that Entity + CoreDateClass.h / m files are a direct replacement for old Entity.h / m files? and that this is actually not a category, despite the file name?
3) For new NSManagedObject subclasses, should I import Entity + CoreDataClass.h, not Entity.h?
4) If I want to uncluttered my project by deleting most of my NSManagedObject subclass files, just delete the files in Xcode and set the codegen entities to the class definition or ...
Is there any magic under the hood that searches for an object + CoreDataClass when trying to #import entity.h, or will I need to go through and find all the links to #import entity.h and change them to #import entity + CoreDataClass.h?
5) Do I correctly assume that if I want to subclass NSManagedObject, where do I want to add the property and method that codegen should set to Category / Extension?
6) If I choose Category / Extension, I have to create my own NSmanagedObject subclass file, its just entity.h not entity + CoreDataClass.h?
7) If entity + CoreDataClass.h is the new accepted naming format for entity.h, why does the generated Category / Extension file look for a simple entity.h file instead of entity + CoreDataClass.h? Is this just an inconsistency in the Apples part and something that I should just accept or am I missing something I should know about?
Thanks.