5

I recently noticed while creating the NSManagedObject subclass two classes are getting created. One is filename+CoreDataProperties.swift and other is filename.swift. Is filename+CoreDataProperties.swift similar to filename.h and filename.swift to filename.m in Objective-c? If so then i can put my implement my logic inside the filename.swift using the +CoreDataProperties.swift class.

I seriously couldnt find out the differences between two these files and whats their use? Any help is appreciated

Danboz
  • 561
  • 1
  • 5
  • 14

1 Answers1

5

I think the filename+CoreDataProperties.swift version gets overwritten every time you export your model from Editor > Create NSManagedObject Subclass (e.g., every time you update your model and need to re-export the class files).

If you have some other, non-Core Data properties (or methods) in your custom subclass, they would be lost every time.

By separating the Core Data-specific code and your custom code, you can export from the Core Data editor as many times as you want without losing your non-Core Data additions.

Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189