1

enter image description here

If you look at Apple's PencilKit Sample, you'll noticed apple used a dataset file called Notes.dataset to save Pencilkit draws. Inside the Notes.dataset, it contains a general json file for Asset Catalogue.

But more interesting, there is a file called color.drawing, which saves the actual data produced by Pencilkit. My question is, how do you create this file as a developer? For example, I want to create a tutorial using Pencilkit and save it as a ".drawing" file, to load up on first launch.

byaruhaf
  • 4,128
  • 2
  • 32
  • 50
Legolas Wang
  • 1,951
  • 1
  • 13
  • 26

1 Answers1

4

PKDrawing is a model layer of PencilKey (and it is opaque), and here is API to store/restore that model:

   func dataRepresentation() -> Data // << to store data in file
   init(data: Data) throws // << to restore from data read from file
Asperi
  • 228,894
  • 20
  • 464
  • 690