0

I added an attribute to my Core Data Stack. I've done this several times in the past, but this was my first time with Xcode 7.

In the past, when I generated new managed object subclasses to reflect the changes in the Data Model, my approach was to replace the old MO subclasses with the new ones. Both old and new used the same name, so it was an easy matter to look at the generation date as a double check.

But now, Xcode generates a different type of file. For example, where my old MO file were named "WMMGAccount.h" and "WMMGAccount.m", the new files are named "WMMGAccount+CoreDataProperties.h" and "WMMGAccount+CoreDataProperties.m".

I see that the new file does an #import "WMMGAccount.h"

My questions are:

1) How should I integrate the new subclass files into the project?

2) How do I reference the new attribute?

rattletrap99
  • 1,469
  • 2
  • 17
  • 36
  • Compare http://stackoverflow.com/questions/34063965/nsmanagedobject-subclass-property-in-category. – Martin R Jun 27 '16 at 04:20
  • That question relates to my problem, but tangentially. The OP says that in his case, Xcode generates 4 files, the standard "XXXX.h/.m" files, and also "XXXX+CoreDataProperties.h/.m". But in my case, Xcode only generated the 2 "XXXX+CoreDataProperties.h/.m" files, perhaps because I already had the "XXXX.h/.m" files. The business about categories and such went over my head, as I've never used them, and don't have a need to use them now. Should I just modify the existing files to include the new attribute as a property, in the fashion of those already included in the original files? – rattletrap99 Jun 27 '16 at 06:45
  • Yes, Xcode does not overwrite the "XXXX.h/.m" files, you can add your additional properties and methods in those files. The "XXXX+CoreDataProperties.h/.m" files are always regenerated from the entity description. – Martin R Jun 27 '16 at 06:54
  • Great! Thanks! If you'd like to formalize your comment in an answer, I'll be pleased to up-vote and accept it. – rattletrap99 Jun 27 '16 at 06:59
  • You are welcome, but I just re-stated what I said in http://stackoverflow.com/a/34064713/1187415 :) – Martin R Jun 27 '16 at 07:03
  • Ok, I guess I got lost in the weeds. Anyway, thanks! I'll up vote your answer over there. – rattletrap99 Jun 27 '16 at 07:04

0 Answers0