Group Group Group Group Group Group Group Group Group

Do we have to call createDocumentURL

In Chapter 7 Memento Pattern, inside the retrieve function in the DiskCaretaker.swift class, we call createDocumentURL. I understand how this is necessary when the app first launches but is it necessary to call createDocumentURL after the first time we have loaded the app?

Are we supposed to create a new URL every time we re-launch the app?

I think that method returns a URL made up of different parts:

(a) some standard & complicated parts, like FileManager.default.urls… and
(b) a file name (String), that you define elsewhere in a caretaker object

“This method simply finds the Documents directory and then appends the given file name”

I don’t think the URL changes once it has been initially created. It remains the same. The static method provides a way of referring to that same URL from other places in your code.

It just happens to be called createDocumentURL (which it technically does), but that doesn’t mean it creates a new URL each time. It creates the same URL each time. It just provides a way of referring to that same URL.

got it since its essentially just fetching the url that we need to find the file in the Bundle