From the course: iPadOS 13 Development Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Saving and loading drawings - iOS Tutorial
From the course: iPadOS 13 Development Essential Training
Saving and loading drawings
- [Instructor] With our delegate method set up, we're ready to start saving data. So let's say when the user is done drawing, we're going to save the data and by done, I mean done drawing a line or when this method gets called. This canvasViewDrawingDidChange method. I'm actually going to delete the other methods and we're going to save the data right here. We can save the data by calling try because the save is going to throw an error and what we're going to do is call canvasView.drawing and we can get a data object through that dataRepresentation method. Then we'll call .write and then we need a URL. So I'll call getImageURL and then we'll define a method called getImageURL. And this is going to return a URL object and this will come from our FileManager. So FileManager.default.urls for .documentDirectory in .userDomainMask. Index zero and then we're going to call .appendingPathComponent and then the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.