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.

Accepted Reply

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.

  • Yeah. That documentation page does not seem to be written in the same manner as other documentation pages where the parameters are used in the description. There doesn't seem to be any consistency. Man, I miss sure Steve Jobs. At least he had standards, IMO.

  • We all miss him…

Add a Comment

Replies

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.

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.

  • Yeah. That documentation page does not seem to be written in the same manner as other documentation pages where the parameters are used in the description. There doesn't seem to be any consistency. Man, I miss sure Steve Jobs. At least he had standards, IMO.

  • We all miss him…

Add a Comment