0

There isn't a lot of information on PencilKit even less on saving PKDrawings to Core Data. But the ones that touch that subject usually turn PKDrawing into Binary Data and save it.

I've found out that PKDrawingReference conforms to NSSecureCoding, which means that it can be stored in Core Data as Transformable by default. From the Apple docs:

A PKDrawingReference object stores the user-drawn content from a PKCanvasView object. You use drawing objects to store the data associated with your user’s drawings. You can save this data with the rest of your app’s content, and you can use that saved data to create a new drawing object later.

Is that the way to go, maybe?

Update: In the end, both of these methods just store Binary Data in Core Data. So we have two ways of doing the same thing. If anyone more knowledgeable can recommend one over the other - feel free to do so.

Oliver
  • 83
  • 5
  • 1
    If you know of a possible solution, why don't you give it a try and see whether it actually works? Waiting for someone to answer your question on SO will take longer than actually trying out the solution. – Dávid Pásztor Jul 18 '23 at 15:05
  • You are right, I've updated my question respectively. Both options store Binary in Core Data. I don't know which one is better as I lack experience beyond that. – Oliver Jul 18 '23 at 15:52

0 Answers0