What is the purpose of 'appropriateFor' property when creating a URL?

The documentation here seems to be incomplete. There is no explanation of the appropriateFor property that is being passed in the example.

I do not understand the relevance of a desktop URL being passed in this example to create a temporary directory.

Example code I have found seem to always pass 'nil' to this property.

Answered by Claude31 in 702139022

Doc says:

… for the domain parameter, and a URL for the url parameter which determines the volume of the returned URL.

domain and url are the parameters names (not the labels):

func url(for directory: FileManager.SearchPathDirectory,  in domain: FileManager.SearchPathDomainMask, appropriateFor url: URL?, create shouldCreate: Bool) throws -> URL

So they effectively refer to in and appropriateFor parameters labels.

Passing nil for url means you ignore it and you do not specify url volume.

Hmmm... Going back to that page and reading again I am now wondering if this is just a type-o?

Maybe the documentation should read "...and a URL for the appropriateFor parameter which determines the volume of the returned URL." ???

If that's the case, then I think I understand the purpose of this parameter.

Accepted Answer

Doc says:

… for the domain parameter, and a URL for the url parameter which determines the volume of the returned URL.

domain and url are the parameters names (not the labels):

func url(for directory: FileManager.SearchPathDirectory,  in domain: FileManager.SearchPathDomainMask, appropriateFor url: URL?, create shouldCreate: Bool) throws -> URL

So they effectively refer to in and appropriateFor parameters labels.

Passing nil for url means you ignore it and you do not specify url volume.

What is the purpose of 'appropriateFor' property when creating a URL?
 
 
Q