NSEntityMigrationPolicy vs NSEntityMapping

349 views Asked by At

To whoever has a good understanding of the migration process of Core Data:

What's the difference (what are their respective roles and their difference) between NSEntityMigrationPolicy and NSEntityMapping?

I don't have any specific problem. I am just curious.

1

There are 1 answers

0
Mundi On BEST ANSWER

NSEntityMapping describes the transformation between entities, attributes and relationships.

NSEntityMigrationPolicy describes the particular process that should be followed when applying the mappings. With the policy you customize the particular stages of the migration life cycle.

In a way it is similar the life cycle callbacks of view controllers. E.g. controllers have views, application logic, etc. but you can inject custom code manipulating these in methods like viewDidLoad, viewWillLayoutSubviews, viewDidAppear, viewWillDisappear, dealloc, etc. if you have to do something at particular stages in the life cycle of the view.

Similarly, NSEntityMigrationPolicy has methods like beginEntityMapping:, endRelationshipCreationForDestinationInstance:, etc.