SwiftUI document app with UIViewRepresentable

I'm attempting to write a document based app that uses UIViewRepresentable to run a PKCanvasView that should save it's drawing data to a slot in an array of PKDrawings I have on my data object.

This is a general structure question as I've been really struggling to with how to connect the dots between the data, UIViewRepresentable and FileDocument struct.

Replies

Your SwiftUI document struct holds the data and handles the saving to a file and loading the data from the file. Your SwiftUI content view has a property for the document. Usually this property uses the @Binding property wrapper. The content view will have the UIView (using UIViewRepresentable) as part of its body. The UIView needs a property to access to whatever data it needs to do the PencilKit drawing. This data is part of the document.

Without more information about your document and data model, no one is going to be able to give you a more detailed answer to this question.