Function

CFURLStartAccessingSecurityScopedResource

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

Declaration

Boolean CFURLStartAccessingSecurityScopedResource(CFURLRef url);

Parameters

url

The security-scoped URL that points to the file-system resource you want to access.

Return Value

true if the request to access the resource succeeded; otherwise, false.

Discussion

When you obtain a security-scoped URL, such as by resolving a security-scoped bookmark, you cannot immediately use the resource it points to. To make the resource available to your app, by way of adding its location to your app’s sandbox, call this function (or its Cocoa equivalent, startAccessingSecurityScopedResource) on the security-scoped URL.

Calls to the CFURLStartAccessingSecurityScopedResource function (or its Cocoa equivalent) are nestable on a per-process basis. This means that if your app calls the start method on a URL twice, to fully relinquish access to the referenced resource you must call the corresponding stop method twice.

See Also

Working with Bookmark Data

CFURLCreateBookmarkData

Returns bookmark data for a URL, created with specified options and resource values.

CFURLCreateBookmarkDataFromAliasRecord

Initializes and returns bookmark data derived from an alias record.

CFURLCreateBookmarkDataFromFile

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

CFURLWriteBookmarkDataToFile

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

CFURLStopAccessingSecurityScopedResource

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software