UIManagedDocument: How to store additional data like a Thumbnail in an iCloud compatbile way?

Hi,

I will be honest with you, I am quite confused on how to store additional content the right way using UIMangedDocument. Unfortunately the documentation on UIMangedDocument seems to be lacking a lot of information.

I am porting my UIDocument based app to a UIManagedDocument based app in order to make use of Core Data. In my UIDocument based approach I just stored additional data via overriding contents(forType:) to return a FileWrapper, which contains the appropriate structure and data like a Thumbnail.

Now it is my understanding, that in order to store additional data with UIManagedDocument you could override additionalContent(for:) which needs to return a Dictionary, not a FileWrapper. I want this to work with iCloud and Apple mentions in the documentation for additionalContent(for:): "Additional content isn’t supported on iCloud." So this does not seem to be the right approach for me.

I could of course store any additional data directly in Core Data's managed object context. But especially in the case of a thumbnail I think this is not the right approach because I would have to create a new UIMangedDocument, open it and then fetch the thumbnail from the persistent store every single time I just want to show a thumbnail for the document.

Also using thumbnailDictionaryKey and fileAttributesToWrite(to:for:) is not the right way as it is deprecated and I want to use the proper new way of a thumbnail extension for showing thumbnails of the documents.

So, what is the right way to store additional data like thumbnails in a UIManagedDocument in a way that is compatible with iCloud?

UIManagedDocument: How to store additional data like a Thumbnail in an iCloud compatbile way?
 
 
Q