V5 Chapter 6 Mapped migration one to many error

Following the steps along to create a custom mapping model, ending at page 157, results in:

2018-12-25 12:23:38.483789-0500 UnCloudNotes[71393:1048312] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unacceptable type of value for to-many relationship: property = "attachments"; desired type = NSSet; given type = NSManagedObject; value = <NSManagedObject: 0x600003ea3070> (entity: Note; id: 0xa2129dc2c43dc805 <x-coredata://65151617-DA34-4A81-AE4B-2AA175760A4B/Note/p1> ; data: {
    attachments =     (
        "0xa2129dc2c43dc805 <x-coredata://65151617-DA34-4A81-AE4B-2AA175760A4B/Note/p1>"
    );
    body = "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamc";
    dateCreated = "2018-12-25 17:03:23 +0000";
    displayIndex = 0;
    title = "Another title";
}).'

I understand what it’s saying but don’t know how to fix it via mapping model file… that’s why I bought the book…

@astralbodies @casademora Can you please help with this when you get a chance? Thank you - much appreciated! :]

@thefredelement Thanks very much for your question!

Could you please share the block of code that caused the above error message?

@thefredelement It looks like the Note object got attached to the note rather than it being an Attachment object. Can you verify that you updated AttachPhotoViewController.swift properly with the changes on page 162-163? Also you might want to uninstall the app from the simulator and try running it fresh.

This topic was automatically closed after 166 days. New replies are no longer allowed.