[ad_1]
TLD;DR: Throughout Core Information migration, find out how to correctly insert a default occasion for the brand new relationship?
I’ve added a brand new required relationship on my Core Information mannequin. In the course of the customized migration course of, I need to create a default worth for that migration for outdated entities.
Nevertheless, when the migration finishes, I am unable to retrieve these new objects.
This is how I arrange a Relationship Mapping expression:
FUNCTION($entityPolicy, "migrate_createDefaultAudioMixWithSource:supervisor:error:" , $supply, $supervisor)

This is my customized migration coverage:
class MigrationPolicy_11To12: NSEntityMigrationPolicy {
@objc(migrate_createDefaultAudioMixWithSource:supervisor:error:)
func migrate_createDefaultAudioMix(supply sInstance: NSManagedObject, supervisor: NSMigrationManager) throws -> NSManagedObject {
let newObject = NSEntityDescription.insertNewObject(forEntityName: "TrackAudioMixParametersEntity",
into: supervisor.destinationContext)
newObject.setValue(UUID(), forKey: "id")
return newObject
}
}
The migration is successfull and the brand new object is certainly added. Nevertheless, when I attempt to entry its properties, Core Information logging an error and returns simply nils.
let _ = monitor.audioMixParameters.id // returns nil and logs error
CoreData: fault: entityForObjectID did not retrieve an NSSQLEntity for objectID 0xb3078b67b6cedaf5 x-coredata://D09D6224-6549-43A2-A7AC-01F40D231C89/TrackAudioMixParametersEntity/p1
CoreData: fault: _sqlCoreLookupSQLEntityForEntityDescription did not return a end result for objectID 0xb3078b67b6cedaf5
[ad_2]
