Swift Slowly: Day 11

Continuing with learning about persistence tutorial

<img alt srcset=​"https:​/​/​docs-assets.developer.apple.com/​published/​8b6dcf46ffef24b1ac64555436587521/​600/​SUI_100-003.png 1x, https:​/​/​docs-assets.developer.apple.com/​published/​0f0b16a34e0c11fdc102fb25bb806d15/​600/​SUI_100-003@2x.png 2x" src=​"https:​/​/​docs-assets.developer.apple.com/​published/​8b6dcf46ffef24b1ac64555436587521/​600/​SUI_100-003.png" width=​"362" height=​"auto">​

Section 3: Method to Load Data

Purpose: Show how to load JSON

This section is pretty cut and dry and I look forward to what the rest of the application looks like. I like the fact that the tutorial shows how to load test data during development.

Section 4: Saving Data

Purpose: This is where the user’s data gets stored from one run to the next.

This is my first time seeing a do-catch statement. I other languages, I’ve seen it as a try-catch and it doesn’t have a specific line on which we are trying.

do {
	let outfile = Self.fileURL
    try data.write(to: outfile)
} catch {
	fatalError("Can't write to file")

Section 5: Save and Load

Purpose: Put the finishing touches on the application.

Other than the part where I put “ObservableObject” instead of “ObservedObject”, I think this was a pretty nice tutorial.