In this SwiftUI tutorial, I am saving the user drawing to the file system with the FileManager. I will modify the model to conform to the Codable protocol. The tricky part is saving Colors.
In the second part, I want to restore the settings for a color picker and slider. This allows to keep all the application state for the next time the user launches my application 🥳. I am saving the values of a slider and color picker to UserDefaults.
Overview:
0:00 Introduction
00:44 Codable protocol and Color
08:50 View model for saving drawing data to file system
16:20 when to save data - ScenePhase and scene life cycle
20:41 saving the selected color to user default
29:42 wrap up
This is the second part of a mini series. You can find the first part here:
How to make a drawing app with SwiftUI 3 - part 1 - Canvas, Shapes, Path and Drag gesture • How to make a drawing app with SwiftU...
You can have a look at the project at this GitHub repository
⬇️ https://github.com/gahntpo/DrawingApp...
If you liked what you learned and you want to see more, check out one of my courses!
👨💻 my SwiftUI course https://school.swiftyplace.com/course...
👨💻 my Core Data and SwiftUI course https://school.swiftyplace.com/course...
👩🏻💻 Combine course https://school.swiftyplace.com/course...
#SaveDataLocally #SwiftUITutorial #FileManager #UserDefaults