mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-24 09:38:30 +02:00
30 lines
997 B
Swift
30 lines
997 B
Swift
//
|
|
// OrganismV2ToV3MigrationPolicy.swift
|
|
// LegacyDemo
|
|
//
|
|
// Created by John Rommel Estropia on 2015/06/27.
|
|
// Copyright © 2018 John Rommel Estropia. All rights reserved.
|
|
//
|
|
|
|
import CoreData
|
|
|
|
class OrganismV2ToV3MigrationPolicy: NSEntityMigrationPolicy {
|
|
|
|
override func createDestinationInstances(forSource sInstance: NSManagedObject, in mapping: NSEntityMapping, manager: NSMigrationManager) throws {
|
|
|
|
try super.createDestinationInstances(forSource: sInstance, in: mapping, manager: manager)
|
|
|
|
for dInstance in manager.destinationInstances(forEntityMappingName: mapping.name, sourceInstances: [sInstance]) {
|
|
|
|
dInstance.setValue(
|
|
false,
|
|
forKey: #keyPath(OrganismV3.hasVertebrae)
|
|
)
|
|
dInstance.setValue(
|
|
sInstance.value(forKey: #keyPath(OrganismV2.numberOfFlippers)),
|
|
forKey: #keyPath(OrganismV3.numberOfLimbs)
|
|
)
|
|
}
|
|
}
|
|
}
|