Tuesday 15 July 2014

ios - Core Data and Private Frameworks -


So, I have an application with many NSManagedObject classes, and I want to remove something Logic and put it into a self-contained structure, which can be used in other applications.

I have a class, let's say:

  employee - first name (one môm property) - last name (one môm property) - (nsstring *) full name ( One method) - (NSUInteger) days more (an ObjC property) - etc ...   

I love to provide this class, and this is a framework MOM definition I understand I am defining the employee there by adding a .mom to the framework, the class .h and .m are made in the framework. When I want to reuse this class, I have to include it in the construction of a project, with the .mom the app will have to merg the mall in the framework, and the institutions will be available to me?

However , I do not think how can I get a unit def / NSManaged object subclass from the structure and then sub-class or expand into a new app . To create a relationship between the essence elements in my app's NSManaged object and the structure, I would have to create sub-categories of structures - I do not know how you can insert a MOM file into a Institutions in other MOM files, either in the form of superclasses or relations sites.

Thoughts? Is it possible to provide an MOM in a framework?

It is true that to expand, it would be strange that a unit in a compiled managed object model The reason you describe is that you describe. As I have seen that you have a few options, in descending order of convenience:

  • uncompiled .xcdatamodel instead of compiled .mom Include> Whatever the compiled model, it can be done by reverse-engineer in any way, so it is not that it leaves any additional information. With the raw model, sub-institutions can be made as normal. If you are worried about the compatibility of existing institutions, then add the run-time check to see employee and make sure it looks as you expect (for example, the unit details Of versionHash ). If the basic framework model has been updated, the changes should be merged explicitly - provided you use the Exode 4 and higher file format for the model.
  • Create sub-entities in the code There is nothing magic about the model editor, whatever you do can be done in code too. You can call setEntities on the managed object model when you first manage and / or modify the model by creating and / or modifying the examples of NSEntityDescription . Just make sure that you are constantly loading the store continuously , because doing so will throw an exception by loading a store file.
  • Store the type of unit in a normal key-value create model and write to employee entity with one relationship from one to the other. You can then add whatever key / value pairs you need to add without having to create a new sub-institution.

    Core data was not actually created with this kind of use, but that does not mean that it is not possible. I take the first option myself, but other people will also work.

No comments:

Post a Comment