Problems with 'ImageTransformer' in Chapter 6 'Versioning and Migration'

Core Data, third edition
Xcode Version 8.2

      • o o o O o o o - - -

p.146 (just before ‘Inferred mapping models’)

After “Build and run the app…”:

  • the app runs ok, notes are preserved, but in the Xcode debug area this warning is seen:

CoreData: warning: no NSValueTransformer with class name ‘ImageTransformer’ was found for attribute ‘image’ on entity ‘Note’

      • o o o O o o o - - -

p.157 (‘Relationship mapping’)
“Select the NoteToNote mapping. Select the attachments relationship row in the list of relationships…”

There is no list to select from. Instead you must create a relationship mapping ‘No Value’, and then select ‘attachments’ (as the only option).

In the Inspector pane, the Relationsip Mapping Name then becomes ‘attachments’, not ‘note’ as shown in the screenshot.

      • o o o O o o o - - -

p.158 (‘One last thing’)
After “Build and run the app…”:

  • the app crashes in ‘CoreDataStack.swift’:

    private lazy var storeContainer: NSPersistentContainer = {
    let container = NSPersistentContainer(name: self.modelName)
    container.persistentStoreDescriptions = [self.storeDescription]
    container.loadPersistentStores { (storeDescription, error) in
    if let error = error {
    fatalError(“Unresolved error (error)”)
    }
    } <=================== exception break point
    return container
    }()

The debug area displays:

CoreData: warning: no NSValueTransformer with class name ‘ImageTransformer’ was found for attribute ‘image’ on entity ‘Note’
CoreData: warning: no NSValueTransformer with class name ‘ImageTransformer’ was found for attribute ‘image’ on entity ‘Attachment’

Kindly
Klaus Kyrsting

UIImage conforms to NSSecureCoding, indirectly conforms to NSCoding, just like UIColor does.
Just need to specify the image attribute with type Transformable. No need to specify any value transformer. CoreData will do the transformation automatically.