Type Method

writeBookmarkData(_:to:options:)

Creates an alias file on disk at a specified location with specified bookmark data.

Declaration

class func writeBookmarkData(_ bookmarkData: Data, to bookmarkFileURL: URL, options: NSURL.BookmarkFileCreationOptions) throws

Parameters

bookmarkData

The bookmark data containing information for the alias file.

bookmarkFileURL

The desired location of the alias file.

options

Options taken into account when creating the alias file.

error

The error that occurred in the case that the alias file cannot be created.

Return Value

true if the alias file is successfully created; otherwise, false.

Discussion

This method will produce an error if bookmarkData was not created with the NSURLBookmarkCreationSuitableForBookmarkFile option.

If bookmarkFileURL points to a directory, the alias file will be created in that directory with its name derived from the information in bookmarkData. If bookmarkFileURL points to a file, the alias file will be created with the location and name indicated by bookmarkFileURL, and its extension will be changed to .alias if it is not already.

See Also

Working with Bookmark Data

class func bookmarkData(withContentsOf: URL)

Initializes and returns bookmark data derived from an alias file pointed to by a specified URL.

class func resourceValues(forKeys: [URLResourceKey], fromBookmarkData: Data)

Returns the resource values for properties identified by a specified array of keys contained in specified bookmark data.

func startAccessingSecurityScopedResource()

In an app that has adopted App Sandbox, makes the resource pointed to by a security-scoped URL available to the app.

func stopAccessingSecurityScopedResource()

In an app that adopts App Sandbox, revokes access to the resource pointed to by a security-scoped URL.

typealias NSURL.BookmarkFileCreationOptions

Options used when creating file bookmark data

struct NSURL.BookmarkCreationOptions

Options used when creating bookmark data.

struct NSURL.BookmarkResolutionOptions

Options used when resolving bookmark data.