0

when i create a new NSManagedObject from Editor at the top, instead of making just a .h and .m file, it makes 4 itme 2 .h and 2 .m with totally different amount of code how which one can i delete? and how can i make them in the old fashion way which had only 1 .h and 1 .m file?

enter image description here

there's also another question, when i have 2 entity while making this class, at the section it asked me to " select the entities you want to manage" should i check my 2 entities at the same time? or its better to make the different NSManagedObject for each one of them?

enter image description here

Arash Afsharpour
  • 1,282
  • 11
  • 22
  • Can you upload your project on Github so we can see what's going on there? – phi Jul 25 '17 at 12:16
  • there's nothing in it, its a new project with core data checkbox checked, i add entity and attributes after that when im in that entity panel i create an NSManagedObject for every Entity after that when i compite i get the error there's nothing in the project – Arash Afsharpour Jul 25 '17 at 12:42
  • I just tried with an empty project and it works fine. You should keep all 4 generated files per entity, do not delete any of them. Did you try to delete the Derived Data folder and restart Xcode? – phi Jul 25 '17 at 13:03
  • yes i did, in Xcode 8 there's no empty project for ios the simplest one is Single View Application! and yes i did try deleting Derived Data folder didn't work yet, do you use XCode 8? how i dont have any empty project? – Arash Afsharpour Jul 25 '17 at 13:22

1 Answers1

1

If you want to use Xcode's code generation tool, you should not delete any of the 4 files since the one uses the other.

However, you don't have to use this tool and you can write your own implementations without any problem. Just remember to mark the properties as @dynamic for the compiler to know they will be implemented during runtime.

This article explains all the above very well.

phi
  • 10,634
  • 6
  • 53
  • 88
  • by XCode's code generation tool you mean creating 'NSManagedObject' in editor menu in data model? and if i want to make the impelementations on my own i should make them 4 file just like Xcode make it? or 1 .h 1.m is enough? and also what is those new file for? im watching Lynda Core Data course and since its for 2012 its totally different at some parts thats why im confused! – Arash Afsharpour Jul 20 '17 at 09:28
  • Exactly, I mean Xcode's option in the "Editor" menu on top – phi Jul 20 '17 at 09:30
  • i hope you can see this, everytime i try to create that object in entity window which make 4 file, i get the error [Topic](https://stackoverflow.com/questions/45259228/how-to-fix-apple-mach-o-linker-error-group-clang-error-linker-command-faile) and this method is for Lynda which is from 2012 and its really old yesterday i watched udemy course which is new and for ios 9 and higher, he wont do such thing and he do all the stuff in ViewControllers class and nothing more i think this way is completely wrong or deprecated. – Arash Afsharpour Jul 25 '17 at 12:07