iOS Developer Library

Developer

Foundation Framework Reference NSURL Class Reference

Options
Deployment Target:

On This Page
Language:

NSURL

An NSURL object represents a URL that can potentially contain the location of a resource on a remote server, the path of a local file on disk, or even an arbitrary piece of encoded data.

You can use URL objects to construct URLs and access their parts. For URLs that represent local files, you can also manipulate properties of those files directly, such as changing the file’s last modification date. Finally, you can pass URL objects to other APIs to retrieve the contents of those URLs. For example, you can use the NSURLSession, NSURLConnection, and NSURLDownload classes to access the contents of remote resources, as described in URL Loading System Programming Guide.

URL objects are the preferred way to refer to local files. Most objects that read data from or write data to a file have methods that accept an NSURL object instead of a pathname as the file reference. For example, you can get the contents of a local file URL as an NSString object by calling the stringWithContentsOfURL:encoding:error: method, or as an NSData object by calling the dataWithContentsOfURL:options:error: method.

You can also use URLs for interapplication communication. In OS X, the NSWorkspace class provides the openURL: method to open a location specified by a URL. Similarly, in iOS, the UIApplication class provides the openURL: method.

Additionally, you can use URLs when working with pasteboards, as described in NSURL Additions Reference (part of the AppKit framework).

Structure of a URL

An NSURL object is composed of two parts—a potentially nil base URL and a string that is resolved relative to the base URL. An NSURL object is considered absolute if its string part is fully resolved without a base; all other URLs are considered relative.

For example, when constructing an NSURL object, you might specify file:///path/to/web_root/ as the base URL and folder/file.html as the string part, as follows:

  • NSURL *baseURL = [NSURL URLWithString:@"file:///path/to/web_root/"];
  • NSURL *url = [NSURL URLWithString:@"folder/file.html" relativeToURL:baseURL];
  • NSURL *absURL = [url absoluteURL];
  • NSLog(@"absURL = %@", absURL);

When fully resolved, the absolute URL is file:///path/to/web_root/folder/file.html.

The URL as a whole can also be divided into pieces based on its structure. For example, the URL https://www.example.com/script?name=value contains a URL scheme (https), a host (www.example.com), a path (/script), and a query string (name=value). The NSURL class provides accessor methods that let you examine those pieces.

Bookmarks and Security Scope

Starting with OS X v10.6 and iOS 4.0, the NSURL class provides a facility for creating and using bookmark objects. A bookmark provides a persistent reference to a file-system resource. When you resolve a bookmark, you obtain a URL to the resource’s current location. A bookmark’s association with a file-system resource (typically a file or folder) usually continues to work if the user moves or renames the resource, or if the user relaunches your app or restarts the system.

For a general introduction to using bookmarks, read Locating Files Using Bookmarks in File System Programming Guide.

In an OS X app that adopts App Sandbox, you can use security-scoped bookmarks to gain access to file-system resources outside your app’s sandbox. These bookmarks preserve the user’s intent to give your app access to a resource across app launches. For details on how this works, including information on the entitlements you need in your Xcode project, read Security-Scoped Bookmarks and Persistent Resource Access in App Sandbox Design Guide. The methods for using security-scoped bookmarks are described in this document in Working with Bookmark Data.

When you resolve a security-scoped bookmark, you get a security-scoped URL.

Security-Scoped URLs

Security-scoped URLs provide access to resources outside an app’s sandbox. In OS X, you get access to security-scoped URLs when you resolve a security-scoped bookmark. In iOS, apps that open or move documents using a UIDocumentPickerViewController also receive security-scoped URLs.

To gain access to a security-scoped URL, you must call the startAccessingSecurityScopedResource method (or its Core Foundation equivalent, the CFURLStartAccessingSecurityScopedResource function). For iOS apps, if you use a UIDocument to access the URL, it automatically manages the security-scoped URL for you.

If startAccessingSecurityScopedResource (or CFUrLStartAccessingSecurityScopedResource) returns YEStrue, you must relinquish your access by calling the stopAccessingSecurityScopedResource method (or its Core Foundation equivalent, the CFURLStopAccessingSecurityScopedResource function). You should relinquish your access as soon as you have finished using the file. After you call these methods, you immediately lose access to the resource in question.

Security-Scoped URLs and String Paths

In an OS X app, when you copy a security-scoped URL, the copy has the security scope of the original. You gain access to the file-system resource (that the URL points to) just as you would with the original URL: by calling the startAccessingSecurityScopedResource method (or its Core Foundation equivalent).

If you need a security-scoped URL’s path as a string value (as provided by the path method), such as to provide to an API that requires a string value, obtain the path from the URL as needed. Note, however, that a string-based path obtained from a security-scoped URL does not have security scope and you cannot use that string to obtain access to a security-scoped resource.

Handling Object Creation Failure

The NSURL class fails to create a new NSURL object if the path being passed is not well formed; the path must comply with RFC 2396. Examples of cases that will not succeed are strings containing space characters and high-bit characters. If creating an NSURL object fails, the creation methods return nil, which you must be prepared to handle. If you are creating NSURL objects using file-system paths, use fileURLWithPath: or initFileURLWithPath:, which handle the subtle differences between URL paths and file system paths. If you want to be tolerant of malformed path strings, use functions provided by the Core Foundation framework to clean up the strings.

Document Thumbnails

With OS X v10.10 and iOS 8.0, the NSURL class includes the ability to get and set document thumbnails as a resource property. In both OS X and iOS, you can get a dictionary of NSImages or UIImages using the getResourceValue:forKey:error: method. On OS X, you can set a dictionary of thumbnails using the setResourceValue:forKey:error: method. You can also get or set all the thumbnails as an NSImage object with multiple representations by using the NSURLThumbnailKey.

  • // Setting a document's thumbnail
  • NSURL *url = [self URLForDocument];
  • //Save the file here...
  • NSImage *thumbnail = [self createDocumentThumbnail];
  • NSError *error = nil;
  • BOOL success =
  • [url setResourceValue:@{NSThumbnail1024x1024SizeKey : thumbnail}
  • forKey:NSURLThumbnailDictionaryKey
  • error:&error];
  • if (!success) {
  • // Handle the error here...
  • }
  • // Getting a document's thumbnail
  • NSURL *url = [self URLForDocument];
  • NSDictionary *thumbnails;
  • NSError *error;
  • BOOL success =
  • [url getResourceValue:&thumbnails
  • forKey:NSURLThumbnailDictionaryKey
  • error:nil];
  • if (!success) {
  • // Handle the error here...
  • }
  • NSImage *image = thumbnails[NSThumbnail1024x1024SizeKey];

Inheritance


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in iOS 2.0 and later.
  • Initializes a newly created NSURL with a specified scheme, host, and path.

    Declaration

    Swift

    convenience init?(scheme scheme: String, host host: String?, path path: String)

    Objective-C

    - (instancetype)initWithScheme:(NSString *)scheme host:(NSString *)host path:(NSString *)path

    Parameters

    scheme

    The scheme for the NSURL object. For example, in the URL http://www.example.com/index.html, the scheme is http.

    host

    The host for the NSURL object (for example, www.example.com). May be the empty string.

    path

    The path for the NSURL object (for example, /index.html). If the path begins with a tilde, you must first expand it by calling stringByExpandingTildeInPath.

    Return Value

    The newly initialized NSURL object.

    Discussion

    This method automatically uses percent encoding to escape the path and host parameters.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Creates and returns an NSURL object initialized with a provided URL string.

    Declaration

    Objective-C

    + (instancetype)URLWithString:(NSString *)URLString

    Parameters

    URLString

    The URL string with which to initialize the NSURL object. Must be a URL that conforms to RFC 2396. This method parses URLString according to RFCs 1738 and 1808.

    Return Value

    An NSURL object initialized with URLString. If the URL string was malformed or nil, returns nil.

    Discussion

    This method expects URLString to contain only characters that are allowed in a properly formed URL. All other characters must be properly percent escaped. Any percent-escaped characters are interpreted using UTF-8 encoding.

    Import Statement

    Objective-C

    @import Foundation;

    Availability

    Available in iOS 2.0 and later.

  • Initializes an NSURL object with a provided URL string.

    Declaration

    Swift

    convenience init?(string URLString: String)

    Objective-C

    - (instancetype)initWithString:(NSString *)URLString

    Parameters

    URLString

    The URL string with which to initialize the NSURL object. This URL string must conform to URL format as described in RFC 2396, and must not be nil. This method parses URLString according to RFCs 1738 and 1808.

    Return Value

    An NSURL object initialized with URLString. If the URL string was malformed, returns nil.

    Discussion

    This method expects URLString to contain only characters that are allowed in a properly formed URL. All other characters must be properly percent escaped. Any percent-escaped characters are interpreted using UTF-8 encoding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

    See Also

    URLWithString:

  • Creates and returns an NSURL object initialized with a base URL and a relative string.

    Declaration

    Objective-C

    + (instancetype)URLWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL

    Parameters

    URLString

    The URL string with which to initialize the NSURL object. May not be nil. Must conform to RFC 2396. URLString is interpreted relative to baseURL.

    baseURL

    The base URL for the NSURL object.

    Return Value

    An NSURL object initialized with URLString and baseURL. If URLString was malformed or nil, returns nil.

    Discussion

    This method allows you to create a URL relative to a base path or URL. For example, if you have the URL for a folder on disk and the name of a file within that folder, you can construct a URL for the file by providing the folder’s URL as the base path (with a trailing slash) and the filename as the string part.

    This method expects URLString to contain only characters that are allowed in a properly formed URL. All other characters must be properly percent escaped. Any percent-escaped characters are interpreted using UTF-8 encoding.

    Import Statement

    Objective-C

    @import Foundation;

    Availability

    Available in iOS 2.0 and later.

  • Initializes an NSURL object with a base URL and a relative string.

    Declaration

    Swift

    init?(string URLString: String, relativeToURL baseURL: NSURL?)

    Objective-C

    - (instancetype)initWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL

    Parameters

    URLString

    The URL string with which to initialize the NSURL object. Must conform to RFC 2396. URLString is interpreted relative to baseURL.

    baseURL

    The base URL for the NSURL object.

    Return Value

    An NSURL object initialized with URLString and baseURL. If URLString was malformed, returns nil.

    Discussion

    This method allows you to create a URL relative to a base path or URL. For example, if you have the URL for a folder on disk and the name of a file within that folder, you can construct a URL for the file by providing the folder’s URL as the base path (with a trailing slash) and the filename as the string part.

    This method expects URLString to contain only characters that are allowed in a properly formed URL. All other characters must be properly percent escaped. Any percent-escaped characters are interpreted using UTF-8 encoding.

    initWithString:relativeToURL: is the designated initializer for NSURL.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Initializes and returns a newly created NSURL object as a file URL with a specified path.

    Declaration

    Swift

    class func fileURLWithPath(_ path: String, isDirectory isDir: Bool) -> NSURL?

    Objective-C

    + (NSURL *)fileURLWithPath:(NSString *)path isDirectory:(BOOL)isDir

    Parameters

    path

    The path that the NSURL object will represent. path should be a valid system path. If path begins with a tilde, it must first be expanded with stringByExpandingTildeInPath. If path is a relative path, it is treated as being relative to the current working directory.

    Passing nil for this parameter produces an exception.

    isDir

    A Boolean value that specifies whether path is treated as a directory path when resolving against relative path components. Pass YEStrue if the path indicates a directory, NOfalse otherwise.

    Return Value

    An NSURL object initialized with path.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Initializes a newly created NSURL referencing the local file or directory at path.

    Declaration

    Swift

    init?(fileURLWithPath path: String, isDirectory isDir: Bool)

    Objective-C

    - (instancetype)initFileURLWithPath:(NSString *)path isDirectory:(BOOL)isDir

    Parameters

    path

    The path that the NSURL object will represent. path should be a valid system path. If path begins with a tilde, it must first be expanded with stringByExpandingTildeInPath. If path is a relative path, it is treated as being relative to the current working directory.

    Passing nil for this parameter produces an exception.

    isDir

    A Boolean value that specifies whether path is treated as a directory path when resolving against relative path components. Pass YEStrue if the path indicates a directory, NOfalse otherwise

    Return Value

    An NSURL object initialized with path.

    Discussion

    Invoking this method is equivalent to invoking initWithScheme:host:path: with scheme NSURLFileScheme, a nil host, and path.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

    See Also

    fileURLWithPath:

  • Initializes and returns a newly created NSURL object as a file URL with a specified path.

    Declaration

    Swift

    class func fileURLWithPath(_ path: String) -> NSURL?

    Objective-C

    + (NSURL *)fileURLWithPath:(NSString *)path

    Parameters

    path

    The path that the NSURL object will represent. path should be a valid system path. If path begins with a tilde, it must first be expanded with stringByExpandingTildeInPath. If path is a relative path, it is treated as being relative to the current working directory.

    Passing nil for this parameter produces an exception.

    Return Value

    An NSURL object initialized with path.

    Discussion

    This method assumes that path is a directory if it ends with a slash. If path does not end with a slash, the method examines the file system to determine if path is a file or a directory. If path exists in the file system and is a directory, the method appends a trailing slash. If path does not exist in the file system, the method assumes that it represents a file and does not append a trailing slash.

    As an alternative, consider using fileURLWithPath:isDirectory:, which allows you to explicitly specify whether the returned NSURL object represents a file or directory.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Initializes a newly created NSURL referencing the local file or directory at path.

    Declaration

    Swift

    init?(fileURLWithPath path: String)

    Objective-C

    - (instancetype)initFileURLWithPath:(NSString *)path

    Parameters

    path

    The path that the NSURL object will represent. path should be a valid system path. If path begins with a tilde, it must first be expanded with stringByExpandingTildeInPath. If path is a relative path, it is treated as being relative to the current working directory.

    Passing nil for this parameter produces an exception.

    Return Value

    An NSURL object initialized with path.

    Discussion

    Invoking this method is equivalent to invoking initWithScheme:host:path: with scheme NSURLFileScheme, a nil host, and path.

    This method assumes that path is a directory if it ends with a slash. If path does not end with a slash, the method examines the file system to determine if path is a file or a directory. If path exists in the file system and is a directory, the method appends a trailing slash. If path does not exist in the file system, the method assumes that it represents a file and does not append a trailing slash.

    As an alternative, consider using initFileURLWithPath:isDirectory:, which allows you to explicitly specify whether the returned NSURL object represents a file or directory.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

    See Also

    fileURLWithPath:

  • Initializes and returns a newly created NSURL object as a file URL with specified path components.

    Declaration

    Swift

    class func fileURLWithPathComponents(_ components: [AnyObject]) -> NSURL?

    Objective-C

    + (NSURL *)fileURLWithPathComponents:(NSArray *)components

    Parameters

    components

    An array of path components.

    Passing nil for this parameter produces an exception.

    Return Value

    An NSURL object initialized with components.

    Discussion

    The path components are separated by a forward slash in the returned URL.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

  • Returns a new URL made by resolving the alias file at url.

    Declaration

    Swift

    convenience init?(byResolvingAliasFileAtURL url: NSURL, options options: NSURLBookmarkResolutionOptions, error error: NSErrorPointer)

    Objective-C

    + (instancetype)URLByResolvingAliasFileAtURL:(NSURL *)url options:(NSURLBookmarkResolutionOptions)options error:(NSError **)error

    Parameters

    url

    The URL pointing to the alias file.

    options

    Options taken into account when resolving the bookmark data. The NSURLBookmarkResolutionWithSecurityScope option is not supported by this method.

    error

    The error that occurred while trying to resolve the provided URL.

    Return Value

    A new URL created by resolving the bookmark data derived from the provided alias file. If an error occurs, this method returns nil.

    Discussion

    Creates and initializes a new URL based on the alias file at url. Use this method to resolve bookmark data that was saved using writeBookmarkData:toURL:options:error: and resolves that data in one step.

    If the url argument does not refer to an alias file as defined by the NSURLIsAliasFileKey property, this method returns the url argument.

    If the url argument is unreachable, this method returns nil and the optional error argument is populated.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 8.0 and later.

  • Returns a new URL made by resolving bookmark data.

    Declaration

    Objective-C

    + (instancetype)URLByResolvingBookmarkData:(NSData *)bookmarkData options:(NSURLBookmarkResolutionOptions)options relativeToURL:(NSURL *)relativeURL bookmarkDataIsStale:(BOOL *)isStale error:(NSError **)error

    Parameters

    bookmarkData

    The bookmark data the URL is derived from.

    options

    Options taken into account when resolving the bookmark data.

    To resolve a security-scoped bookmark to support App Sandbox, you must include (by way of bitwise OR operators with any other options in this parameter) the NSURLBookmarkResolutionWithSecurityScope option.

    relativeURL

    The base URL that the bookmark data is relative to.

    If you are resolving a security-scoped bookmark to obtain a security-scoped URL, use this parameter as follows:

    • To resolve an app-scoped bookmark, use a value of nil.

    • To resolve a document-scoped bookmark, use the absolute path (despite this parameter’s name) to the document from which you retrieved the bookmark.

    isStale

    On return, if YEStrue, the bookmark data is stale. Your app should create a new bookmark using the returned URL and use it in place of any stored copies of the existing bookmark.

    error

    The error that occurred in the case that the URL cannot be created.

    Return Value

    A new URL made by resolving bookmarkData.

    Discussion

    This method fails if the original file or directory could not be located or is on a volume that could not be mounted. If this method fails, you can use the resourceValuesForKeys:fromBookmarkData: method to obtain information about the bookmark, such as the last known path (NSURLPathKey) to help the user decide how to proceed.

    To obtain a security-scoped URL from a security-scoped bookmark, call this method using the NSURLBookmarkResolutionWithSecurityScope option. In addition, to use security scope, you must first have enabled the appropriate entitlements for your app, as described in Enabling Security-Scoped Bookmark and URL Access.

    To then obtain access to the file-system resource pointed to by a security-scoped URL (in other words, to bring the resource into your app’s sandbox), call the startAccessingSecurityScopedResource method (or its Core Foundation equivalent, the CFURLStartAccessingSecurityScopedResource function) on the URL.

    For an app-scoped bookmark, no sandboxed app other than the one that created the bookmark can obtain access to the file-system resource that the URL (obtained from the bookmark) points to.

    For a document-scoped bookmark, any sandboxed app that has access to the bookmark data itself, and has access to the document that owns the bookmark, can obtain access to the resource.

    Import Statement

    Objective-C

    @import Foundation;

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

  • Initializes a newly created NSURL that points to a location specified by resolving bookmark data.

    Declaration

    Swift

    convenience init?(byResolvingBookmarkData bookmarkData: NSData, options options: NSURLBookmarkResolutionOptions, relativeToURL relativeURL: NSURL?, bookmarkDataIsStale isStale: UnsafeMutablePointer<ObjCBool>, error error: NSErrorPointer)

    Objective-C

    - (instancetype)initByResolvingBookmarkData:(NSData *)bookmarkData options:(NSURLBookmarkResolutionOptions)options relativeToURL:(NSURL *)relativeURL bookmarkDataIsStale:(BOOL *)isStale error:(NSError **)error

    Parameters

    bookmarkData

    The bookmark data the URL is derived from.

    options

    Options taken into account when resolving the bookmark data.

    relativeURL

    The base URL that the bookmark data is relative to.

    isStale

    If YEStrue, the bookmark data is stale.

    error

    The error that occurred in the case that the URL cannot be created.

    Return Value

    An NSURL initialized by resolving bookmarkData.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

  • Returns a new URL object initialized with a C string representing a local file system path.

    Declaration

    Swift

    class func fileURLWithFileSystemRepresentation(_ path: UnsafePointer<Int8>, isDirectory isDir: Bool, relativeToURL baseURL: NSURL?) -> NSURL?

    Objective-C

    + (NSURL *)fileURLWithFileSystemRepresentation:(const char *)path isDirectory:(BOOL)isDir relativeToURL:(NSURL *)baseURL

    Parameters

    path

    A null-terminated C string in file system representation containing the path to represent as a URL. If this path is a relative path, it is treated as being relative to the current working directory.

    isDir

    YEStrue if the last path part is a directory, otherwise NOfalse.

    baseURL

    The base URL for the new URL object. This must be a file URL. If path is absolute, this URL is ignored.

    Return Value

    Returns the new object or nil if an error occurred.

    Discussion

    The file system representation format is described in File Encodings and Fonts.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 7.0 and later.

  • Fills the provided buffer with a C string representing a local file system path.

    Declaration

    Swift

    func getFileSystemRepresentation(_ buffer: UnsafeMutablePointer<Int8>, maxLength maxBufferLength: Int) -> Bool

    Objective-C

    - (BOOL)getFileSystemRepresentation:(char *)buffer maxLength:(NSUInteger)maxBufferLength

    Parameters

    buffer

    A buffer large enough to hold the path. On return, contains a null-terminated C string in file system representation.

    maxBufferLength

    The size of buffer in bytes (typically MAXPATHLEN or PATH_MAX).

    Return Value

    Returns YEStrue if the URL could be converted into a file system representation, otherwise NOfalse.

    Discussion

    The file system representation format is described in File Encodings and Fonts.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 7.0 and later.

  • Initializes a URL object with a C string representing a local file system path.

    Declaration

    Swift

    init?(fileURLWithFileSystemRepresentation path: UnsafePointer<Int8>, isDirectory isDir: Bool, relativeToURL baseURL: NSURL?)

    Objective-C

    - (instancetype)initFileURLWithFileSystemRepresentation:(const char *)path isDirectory:(BOOL)isDir relativeToURL:(NSURL *)baseURL

    Parameters

    path

    A null-terminated C string in file system representation containing the path to represent as a URL. If this path is a relative path, it is treated as being relative to the current working directory.

    isDir

    YEStrue if the last path part is a directory, otherwise NOfalse.

    baseURL

    The base URL for the new URL object. This must be a file URL. If path is absolute, this URL is ignored.

    Return Value

    Returns the initialized object or nil if an error occurred.

    Discussion

    The file system representation format is described in File Encodings and Fonts.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 7.0 and later.

  • Returns a Boolean value that indicates whether the receiver and a given object have identical URL strings and base URLs.

    Declaration

    Objective-C

    - (BOOL)isEqual:(id)anObject

    Parameters

    anObject

    The object to be compared to the receiver.

    Return Value

    YEStrue if the receiver and anObject are equal, otherwise NOfalse.

    Discussion

    This method defines what it means for instances to be equal. Two NSURLs are considered equal if and only if they return identical values for both baseURL and relativeString.

  • Returns whether the resource pointed to by a file URL can be reached.

    Declaration

    Swift

    func checkResourceIsReachableAndReturnError(_ error: NSErrorPointer) -> Bool

    Objective-C

    - (BOOL)checkResourceIsReachableAndReturnError:(NSError **)error

    Parameters

    error

    The error that occurred when the resource could not be reached.

    Return Value

    YEStrue if the resource is reachable; otherwise, NOfalse.

    Discussion

    This method synchronously checks if the file at the provided URL is reachable. Checking reachability is appropriate when making decisions that do not require other immediate operations on the resource, such as periodic maintenance of user interface state that depends on the existence of a specific document. For example, you might remove an item from a download list if the user deletes the file.

    If your app must perform operations on the file, such as opening it or copying resource properties, it is more efficient to attempt the operation and handle any failure that may occur.

    If this method returns NOfalse, the object pointer referenced by error is populated with additional information.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

  • Returns whether the URL is a file reference URL.

    Declaration

    Swift

    func isFileReferenceURL() -> Bool

    Objective-C

    - (BOOL)isFileReferenceURL

    Return Value

    YEStrue if the URL is a file reference URL; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

  • fileURL fileURL Property

    A boolean value that determines whether the receiver is a file URL. (read-only)

    Declaration

    Swift

    var fileURL: Bool { get }

    Objective-C

    @property(readonly, getter=isFileURL) BOOL fileURL

    Discussion

    The property’s value is YEStrue if the receiver uses the file scheme, NOfalse otherwise. Both file path and file reference URLs are considered to be file URLs.

    If this property’s value is YEStrue, then the receiver’s path property contains a suitable value for input into NSFileManager or NSPathUtilities.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 8.0 and later.

  • The URL string for the receiver as an absolute URL. (read-only)

    Declaration

    Swift

    var absoluteString: String? { get }

    Objective-C

    @property(readonly, copy) NSString *absoluteString

    Discussion

    This property’s value is calculated by resolving the receiver’s string against its base according to the algorithm given in RFC 1808.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • An absolute URL that refers to the same resource as the receiver. (read-only)

    Declaration

    Swift

    @NSCopying var absoluteURL: NSURL? { get }

    Objective-C

    @property(readonly, copy) NSURL *absoluteURL

    Discussion

    If the URL is already absolute, this property contains a copy of the receiver. Resolution is performed per RFC 1808.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • baseURL baseURL Property

    The base URL. (read-only)

    Declaration

    Swift

    @NSCopying var baseURL: NSURL? { get }

    Objective-C

    @property(readonly, copy) NSURL *baseURL

    Discussion

    This property contains the base URL. If the receiver is an absolute URL, this property contains nil.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • A C string containing the URL’s file system path. (read-only)

    Declaration

    Swift

    var fileSystemRepresentation: UnsafePointer<Int8> { get }

    Objective-C

    @property(readonly) const char *fileSystemRepresentation

    Discussion

    This returns a null-terminated C string in file system representation.

    This string is automatically freed in the same way that a returned object would be released. The caller must either copy the string or use getFileSystemRepresentation:maxLength: if it needs to store the representation outside of the autorelease context in which the value was obtained.

    The file system representation format is described in File Encodings and Fonts.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 7.0 and later.

  • fragment fragment Property

    The fragment identifier, conforming to RFC 1808. (read-only)

    Declaration

    Swift

    var fragment: String? { get }

    Objective-C

    @property(readonly, copy) NSString *fragment

    Discussion

    This property contains the URL’s fragment. If the receiver does not conform to RFC 1808, this property contains nil. For example, in the URL http://www.example.com/index.html#jumpLocation, the fragment identifier is jumpLocation.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • host host Property

    The host, conforming to RFC 1808. (read-only)

    Declaration

    Swift

    var host: String? { get }

    Objective-C

    @property(readonly, copy) NSString *host

    Discussion

    This property contains the host. For example, in the URL http://www.example.com/index.html, the host is www.example.com.

    If the receiver does not conform to RFC 1808, this property contains nil. The litmus test for conformance to RFC 1808 is as recommended in RFC 1808—specifically, whether the first two characters of resourceSpecifier are slashes (//).

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • The last path component. (read-only)

    Declaration

    Swift

    var lastPathComponent: String? { get }

    Objective-C

    @property(readonly, copy) NSString *lastPathComponent

    Discussion

    This property contains the last path component. For example, in the URL file:///path/to/file, the last path component is file.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

  • The parameter string conforming to RFC 1808. (read-only)

    Declaration

    Swift

    var parameterString: String? { get }

    Objective-C

    @property(readonly, copy) NSString *parameterString

    Discussion

    This property contains the parameter string. If the receiver does not conform to RFC 1808, this property contains nil. For example, in the URL file:///path/to/file;foo, the parameter string is foo.

    This property should not be confused with the query property, which also often contains a string of parameters.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • password password Property

    The password conforming to RFC 1808. (read-only)

    Declaration

    Swift

    var password: String? { get }

    Objective-C

    @property(readonly, copy) NSString *password

    Discussion

    This property contains the password. If the receiver does not conform to RFC 1808, it contains nil. For example, in the URL http://username:password@www.example.com/index.html, the password is password.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • path path Property

    The path, conforming to RFC 1808. (read-only)

    Declaration

    Swift

    var path: String? { get }

    Objective-C

    @property(readonly, copy) NSString *path

    Discussion

    This property contains the path, unescaped with the stringByReplacingPercentEscapesUsingEncoding: method. If the receiver does not conform to RFC 1808, this property contains nil.

    If the receiver contains a file or file reference URL (as determined with isFileURL), this property’s value is suitable for input into methods of NSFileManager or NSPathUtilities. If the path has a trailing slash, it is stripped.

    If the receiver contains a file reference URL, this property’s value provides the current path for the referenced resource, which may be nil if the resource no longer exists.

    If the parameterString property contains a non-nil value, the path may be incomplete. If the receiver contains an unencoded semicolon, the path property ends at the character before the semicolon. The remainder of the URL is provided in the parameterString property.

    To obtain the complete path, if parameterString contains a non-nil value, append a semicolon, followed by the parameter string.

    Per RFC 3986, the leading slash after the authority (host name and port) portion is treated as part of the path. For example, in the URL http://www.example.com/index.html, the path is /index.html.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • An array containing the path components. (read-only)

    Declaration

    Swift

    var pathComponents: [AnyObject]? { get }

    Objective-C

    @property(readonly, copy) NSArray *pathComponents

    Discussion

    This property contains an array containing the individual path components of the URL. For example, in the URL file:///directory/directory2/file, the path components array would be @[@"/", @"directory", @"directory2", @"file"].

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

  • The path extension. (read-only)

    Declaration

    Swift

    var pathExtension: String? { get }

    Objective-C

    @property(readonly, copy) NSString *pathExtension

    Discussion

    This property contains the path extension. For example, in the URL file:///path/to/file.txt, the path extension is txt.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

  • port port Property

    The port, conforming to RFC 1808. (read-only)

    Declaration

    Swift

    @NSCopying var port: NSNumber? { get }

    Objective-C

    @property(readonly, copy) NSNumber *port

    Discussion

    This property contains the port number. For example, in the URL http://www.example.com:8080/index.php, the port number is 8080.

    If the receiver does not conform to RFC 1808, this property contains nil. The litmus test for conformance to RFC 1808 is as recommended in RFC 1808—specifically, whether the first two characters of resourceSpecifier are slashes (//).

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • query query Property

    The query string, conforming to RFC 1808. (read-only)

    Declaration

    Swift

    var query: String? { get }

    Objective-C

    @property(readonly, copy) NSString *query

    Discussion

    This property contains the query string. If the receiver does not conform to RFC 1808, this property contains nil. For example, in the URL http://www.example.com/index.php?key1=value1&key2=value2, the query string is key1=value1&key2=value2.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • The relative path, conforming to RFC 1808. (read-only)

    Declaration

    Swift

    var relativePath: String? { get }

    Objective-C

    @property(readonly, copy) NSString *relativePath

    Discussion

    This property contains the relative path of the receiver’s URL without resolving against its base URL. If the path has a trailing slash it is stripped. If the receiver is an absolute URL, this property contains the same value as path. If the receiver does not conform to RFC 1808, it contains nil.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • A string representation of the relative portion of the URL. (read-only)

    Declaration

    Swift

    var relativeString: String? { get }

    Objective-C

    @property(readonly, copy) NSString *relativeString

    Discussion

    This property contains a string representation of the relative portion of the URL. If the receiver is an absolute URL this method returns the same value as absoluteString.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • The resource specifier. (read-only)

    Declaration

    Swift

    var resourceSpecifier: String? { get }

    Objective-C

    @property(readonly, copy) NSString *resourceSpecifier

    Discussion

    This property contains the resource specifier. For example, in the URL http://www.example.com/index.html?key1=value1#jumplink, the resource specifier is //www.example.com/index.html?key1=value1#jumplink (everything after the colon).

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • scheme scheme Property

    The scheme. (read-only)

    Declaration

    Swift

    var scheme: String? { get }

    Objective-C

    @property(readonly, copy) NSString *scheme

    Discussion

    This property contains the scheme. For example, in the URL http://www.example.com/index.html, the scheme is http.

    The full URL is the concatenation of the scheme, a colon (:), and the value of resourceSpecifier.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • A copy of the URL with any instances of ".." or "." removed from its path. (read-only)

    Declaration

    Swift

    @NSCopying var standardizedURL: NSURL? { get }

    Objective-C

    @property(readonly, copy) NSURL *standardizedURL

    Discussion

    This property contains a new NSURL object, initialized using the receiver’s path with any instances of ".." or "." removed.

    If the URL conforms to RFC 1808 (the most common form of URL), this property contains the specified URL component; otherwise it contains nil. The litmus test for conformance to RFC 1808 is as recommended in RFC 1808—specifically, whether the first two characters of resourceSpecifier are slashes (//).

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • user user Property

    The user name, conforming to RFC 1808. (read-only)

    Declaration

    Swift

    var user: String? { get }

    Objective-C

    @property(readonly, copy) NSString *user

    Discussion

    This property contains the user name. For example, in the URL ftp://username@www.example.com/, the user name is username.

    If the receiver’s URL does not conform to RFC 1808, this property returns nil. The litmus test for conformance to RFC 1808 is as recommended in RFC 1808—specifically, whether the first two characters of resourceSpecifier are slashes (//).

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • A file path URL that points to the same resource as the URL object. (read-only)

    Declaration

    Swift

    @NSCopying var filePathURL: NSURL? { get }

    Objective-C

    @property(readonly, copy) NSURL *filePathURL

    Discussion

    If the receiver is a file reference URL, this property contains a copy of the URL converted to a file path URL. If the receiver’s URL is a file path URL, this property contains the original URL. If the original URL is not a file URL, or if the resource is not reachable or no longer exists, this property contains nil.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

  • Returns a new file reference URL that points to the same resource as the receiver.

    Declaration

    Swift

    func fileReferenceURL() -> NSURL?

    Objective-C

    - (NSURL *)fileReferenceURL

    Return Value

    The new file reference URL.

    Discussion

    File reference URLs use a URL path syntax that identifies a file system object by reference, not by path. This form of file URL remains valid when the file system path of the URL’s underlying resource changes.

    If the original URL is a file path URL, this property contains a copy of the URL converted into a file reference URL. If the original URL is a file reference URL, this property contains the original. If the original URL is not a file URL, this property contains nil.

    File reference URLs cannot be created to file system objects which do not exist or are not reachable. This property contains nil instead.

    In some areas of the file system hierarchy, file reference URLs cannot be generated to the leaf node of the URL path.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

  • Returns a new URL made by appending a path component to the original URL.

    Declaration

    Swift

    func URLByAppendingPathComponent(_ pathComponent: String) -> NSURL

    Objective-C

    - (NSURL *)URLByAppendingPathComponent:(NSString *)pathComponent

    Parameters

    pathComponent

    The path component to add to the URL, in its original form (not URL encoded).

    Return Value

    A new URL with pathComponent appended.

    Discussion

    If the original URL does not end with a forward slash and pathComponent does not begin with a forward slash, a forward slash is inserted between the two parts of the returned URL, unless the original URL is the empty string.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

  • Returns a new URL made by appending a path component to the original URL, along with a trailing slash if the component is designated a directory.

    Declaration

    Swift

    func URLByAppendingPathComponent(_ pathComponent: String, isDirectory isDirectory: Bool) -> NSURL

    Objective-C

    - (NSURL *)URLByAppendingPathComponent:(NSString *)pathComponent isDirectory:(BOOL)isDirectory

    Parameters

    pathComponent

    The path component to add to the URL.

    isDirectory

    If YEStrue, a trailing slash is appended after pathComponent.

    Return Value

    A new URL with pathComponent appended.

    Discussion

    If the original URL does not end with a forward slash and pathComponent does not begin with a forward slash, a forward slash is inserted between the two parts of the returned URL, unless the original URL is the empty string.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later.

  • Returns a new URL made by appending a path extension to the original URL.

    Declaration

    Swift

    func URLByAppendingPathExtension(_ pathExtension: String) -> NSURL

    Objective-C

    - (NSURL *)URLByAppendingPathExtension:(NSString *)pathExtension

    Parameters

    pathExtension

    The path extension to add to the URL.

    Return Value

    A new URL with pathExtension appended.

    Discussion

    If the original URL ends with one or more forward slashes, these are removed from the returned URL. A period is inserted between the two parts of the new URL.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

  • A URL created by taking the receiver and removing the last path component. (read-only)

    Declaration

    Swift

    @NSCopying var URLByDeletingLastPathComponent: NSURL? { get }

    Objective-C

    @property(readonly, copy) NSURL *URLByDeletingLastPathComponent

    Discussion

    If the receiver’s URL represents the root path, this property contains a copy of the original URL. Otherwise, if the original URL has only one path component, this property contains the empty string.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

  • A URL created by taking the receiver and removing the path extension, if any. (read-only)

    Declaration

    Swift

    @NSCopying var URLByDeletingPathExtension: NSURL? { get }

    Objective-C

    @property(readonly, copy) NSURL *URLByDeletingPathExtension

    Discussion

    If the receiver represents the root path, this property contains a copy of the original URL. If the URL has multiple path extensions, only the last one is removed.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

  • A URL that points to the same resource as the receiver and includes no symbolic links. (read-only)

    Declaration

    Swift

    @NSCopying var URLByResolvingSymlinksInPath: NSURL? { get }

    Objective-C

    @property(readonly, copy) NSURL *URLByResolvingSymlinksInPath

    Discussion

    If the receiver has no symbolic links, this property contains a copy of the original URL.

    If some symbolic links cannot be resolved, this property contains those broken symbolic links.

    If the name of the receiving path begins with /private, this property strips off the /private designator, provided the result is the name of an existing file.

    This property only works on URLs with the file: path scheme. For all other URLs, it contains a copy of the receiver.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

  • A URL that points to the same resource as the original URL using an absolute path. (read-only)

    Declaration

    Swift

    @NSCopying var URLByStandardizingPath: NSURL? { get }

    Objective-C

    @property(readonly, copy) NSURL *URLByStandardizingPath

    Discussion

    This property only works on URLs with the file: path scheme. For all other URLs, it returns a copy of the original URL.

    Like stringByStandardizingPath, this property can make the following changes in the provided URL:

    • Expand an initial tilde expression using stringByExpandingTildeInPath.

    • Reduce empty components and references to the current directory (that is, the sequences “//” and “/./”) to single path separators.

    • In absolute paths only, resolve references to the parent directory (that is, the component “..”) to the real parent directory if possible using stringByResolvingSymlinksInPath, which consults the file system to resolve each potential symbolic link.

      In relative paths, because symbolic links can’t be resolved, references to the parent directory are left in place.

    • Remove an initial component of “/private” from the path if the result still indicates an existing file or directory (checked by consulting the file system).

    Note that the path contained by this property may still have symbolic link components in it. Note also that this property only works with file paths (not, for example, string representations of URLs).

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

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

    Declaration

    Swift

    class func bookmarkDataWithContentsOfURL(_ bookmarkFileURL: NSURL, error error: NSErrorPointer) -> NSData?

    Objective-C

    + (NSData *)bookmarkDataWithContentsOfURL:(NSURL *)bookmarkFileURL error:(NSError **)error

    Parameters

    bookmarkFileURL

    The URL that points to the alias file.

    error

    The error that occurred in the case that the bookmark data cannot be derived.

    Return Value

    The bookmark data for the alias file.

    Discussion

    If bookmarkFileURL points to an alias file created prior to OS X v10.6 that contains Alias Manager information but no bookmark data, this method synthesizes bookmark data for the file.

    This method returns nil if bookmark data cannot be created.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

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

    Declaration

    Swift

    func bookmarkDataWithOptions(_ options: NSURLBookmarkCreationOptions, includingResourceValuesForKeys keys: [AnyObject]?, relativeToURL relativeURL: NSURL?, error error: NSErrorPointer) -> NSData?

    Objective-C

    - (NSData *)bookmarkDataWithOptions:(NSURLBookmarkCreationOptions)options includingResourceValuesForKeys:(NSArray *)keys relativeToURL:(NSURL *)relativeURL error:(NSError **)error

    Parameters

    options

    Options taken into account when creating the bookmark for the URL. The possible flags (which can be combined with bitwise OR operations) are described in Bookmark Data Creation Options.

    To create a security-scoped bookmark to support App Sandbox, include the NSURLBookmarkCreationWithSecurityScope flag. When you later resolve the bookmark, you can use the resulting security-scoped URL to obtain read/write access to the file-system resource pointed to by the URL.

    If you instead want to create a security-scoped bookmark that, when resolved, enables you to obtain read-only access to a file-system resource, bitwise OR this parameter’s value with both the NSURLBookmarkCreationWithSecurityScope option and the NSURLBookmarkCreationSecurityScopeAllowOnlyReadAccess option.

    keys

    An array of names of URL resource properties to store as part of the bookmark. You can later access these values (without resolving the bookmark) by calling the resourceValuesForKeys:fromBookmarkData: method.

    The values of these properties must be of a type that the bookmark generation code can serialize. Specifically, the values can contain any of the following primitive types:

    • NSString or CFString

    • NSData or CFData

    • NSDate or CFDate

    • NSNumber or CFNumber

    • CFBoolean

    • NSURL or CFURL

    • kCFNull or NSNull

    • CFUUID

    In addition, the properties can contain the following collection classes:

    • NSArray or CFArray containing only the above primitive types

    • NSDictionary or CFDictionary with NSString or CFString keys, in which all values contain only the above primitive types

    relativeURL

    The URL that the bookmark data will be relative to.

    If you are creating a security-scoped bookmark to support App Sandbox, use this parameter as follows:

    • To create an app-scoped bookmark, use a value of nil.

    • To create a document-scoped bookmark, use the absolute path (despite this parameter’s name) to the document file that is to own the new security-scoped bookmark.

    error

    The error that occurred in the case that the bookmark data cannot be created.

    Return Value

    A bookmark for the URL.

    Discussion

    This method returns bookmark data that can later be resolved into a URL object for a file even if the user moves or renames it (if the volume format on which the file resides supports doing so).

    You can also use this method to create a security-scoped bookmark to support App Sandbox. Before you do so, you must first enable the appropriate entitlements for your app, as described in Enabling Security-Scoped Bookmark and URL Access. In addition, be sure to understand the behavior of the options and relativeURL parameters.

    For an app-scoped bookmark, no sandboxed app other than the one that created the bookmark can obtain access to the file-system resource that the URL (obtained from the bookmark) points to. Specifically, a bookmark created with security scope fails to resolve if the caller does not have the same code signing identity as the caller that created the bookmark.

    For a document-scoped bookmark, any sandboxed app that has access to the bookmark data itself, and has access to the document that owns the bookmark, can obtain access to the resource.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

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

    Declaration

    Swift

    class func resourceValuesForKeys(_ keys: [AnyObject], fromBookmarkData bookmarkData: NSData) -> [NSObject : AnyObject]?

    Objective-C

    + (NSDictionary *)resourceValuesForKeys:(NSArray *)keys fromBookmarkData:(NSData *)bookmarkData

    Parameters

    keys

    An array of names of URL resource properties. In addition to the standard, system-defined resource properties, you can also request any custom properties that you provided when you created the bookmark. See the bookmarkDataWithOptions:includingResourceValuesForKeys:relativeToURL:error: method for details.

    bookmarkData

    The bookmark data from which you want to retrieve resource values.

    Return Value

    A dictionary of the requested resource values contained in bookmarkData.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

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

    Declaration

    Swift

    class func writeBookmarkData(_ bookmarkData: NSData, toURL bookmarkFileURL: NSURL, options options: NSURLBookmarkFileCreationOptions, error error: NSErrorPointer) -> Bool

    Objective-C

    + (BOOL)writeBookmarkData:(NSData *)bookmarkData toURL:(NSURL *)bookmarkFileURL options:(NSURLBookmarkFileCreationOptions)options error:(NSError **)error

    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

    YEStrue if the alias file is successfully created; otherwise, NOfalse.

    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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

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

    Declaration

    Swift

    func startAccessingSecurityScopedResource() -> Bool

    Objective-C

    - (BOOL)startAccessingSecurityScopedResource

    Return Value

    YEStrue if the request to access the resource succeeded; otherwise, NOfalse.

    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 method (or its Core Foundation equivalent, the CFURLStartAccessingSecurityScopedResource function) on the security-scoped URL.

    If this method returns YEStrue, then you must relinquish access as soon as you finish using the resource. Call the stopAccessingSecurityScopedResource method to relinquish access. When you call the stopAccessingSecurityScopedResource method, you immediately lose access to the resource in question.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 8.0 and later.

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

    Declaration

    Swift

    func stopAccessingSecurityScopedResource()

    Objective-C

    - (void)stopAccessingSecurityScopedResource

    Discussion

    When you no longer need access to a file or directory pointed to by a security-scoped URL, such as one returned by resolving a security-scoped bookmark, call this method (or its Core Foundation equivalent, the CFURLStopAccessingSecurityScopedResource function) on the URL to relinquish access. When you call this method, you immediately lose access to the resource in question.

    If you call this method on a URL whose referenced resource you do not have access to, nothing happens.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 8.0 and later.

  • Returns the value of the resource property for the specified key.

    Declaration

    Swift

    func getResourceValue(_ value: AutoreleasingUnsafeMutablePointer<AnyObject?>, forKey key: String, error error: NSErrorPointer) -> Bool

    Objective-C

    - (BOOL)getResourceValue:(out id *)value forKey:(NSString *)key error:(out NSError **)error

    Parameters

    value

    The location where the value for the resource property identified by key should be stored.

    key

    The name of one of the URL’s resource properties.

    error

    The error that occurred if the resource value could not be retrieved. This parameter is optional. If you are not interested in receiving error information, you can pass nil.

    Return Value

    YEStrue if value is successfully populated; otherwise, NOfalse.

    Discussion

    This method first checks if the URL object already caches the resource value. If so, it returns the cached resource value to the caller. If not, then this method synchronously obtains the resource value from the backing store, adds the resource value to the URL object's cache, and returns the resource value to the caller.

    The type of the returned resource value varies by resource property; for details, see the documentation for the key you want to access.

    If this method returns YEStrue and the value is populated with nil, it means that the resource property is not available for the specified resource, and that no errors occurred when determining that the resource property was unavailable.

    If this method returns NOfalse, an error occurred. The object pointer referenced by error is populated with additional information.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

  • Returns the resource values for the properties identified by specified array of keys.

    Declaration

    Swift

    func resourceValuesForKeys(_ keys: [AnyObject], error error: NSErrorPointer) -> [NSObject : AnyObject]?

    Objective-C

    - (NSDictionary *)resourceValuesForKeys:(NSArray *)keys error:(NSError **)error

    Parameters

    keys

    An array of property keys for the desired resource properties.

    error

    The error that occurred if one or more resource values could not be retrieved. This parameter is optional. If you are not interested in receiving error information, you can pass nil.

    Return Value

    A dictionary of resource values indexed by key.

    Discussion

    This method first checks if the URL object already caches the specified resource values. If so, it returns the cached resource values to the caller. If not, then this method synchronously obtains the resource values from the backing store, adds the resource values to the URL object's cache, and returns the resource values to the caller.

    The type of the returned resource value varies by resource property; for details, see the documentation for the key you want to access.

    If the result dictionary does not contain a resource value for one or more of the requested resource keys, it means those resource properties are not available for the URL, and no errors occurred when determining those resource properties were not available.

    If an error occurs, this method returns nil and populates the object pointer referenced by error with additional information.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

  • Sets the URL’s resource property for a given key to a given value.

    Declaration

    Swift

    func setResourceValue(_ value: AnyObject?, forKey key: String, error error: NSErrorPointer) -> Bool

    Objective-C

    - (BOOL)setResourceValue:(id)value forKey:(NSString *)key error:(NSError **)error

    Parameters

    value

    The value for the resource property defined by key.

    key

    The name of one of the URL’s resource properties.

    error

    The error that occurred if the resource value could not be set.

    Return Value

    YEStrue if the resource property named key is successfully set to value; otherwise, NOfalse.

    Discussion

    This method synchronously writes the new resource value out to disk. Attempts to set a read-only resource property or to set a resource property that is not supported by the resource are ignored and are not considered errors.

    If an error occurs, this method returns NOfalse and populates the object pointer referenced by error with additional information.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

  • Sets the URL’s resource properties for a given set of keys to a given set of values.

    Declaration

    Swift

    func setResourceValues(_ keyedValues: [NSObject : AnyObject], error error: NSErrorPointer) -> Bool

    Objective-C

    - (BOOL)setResourceValues:(NSDictionary *)keyedValues error:(NSError **)error

    Parameters

    keyedValues

    A dictionary of resource values to be set.

    error

    The error that occurred if one or more resource values could not be set.

    Return Value

    YEStrue if all resource values in keyedValues are successfully set; otherwise, NOfalse.

    Discussion

    This method synchronously writes the new resource value out to disk. If an error occurs after some resource properties have been successfully changed, the userInfo dictionary in the returned error object contains a kCFURLKeysOfUnsetValuesKey key whose value is an array of the resource values that were not successfully set.

    Attempts to set a read-only resource property or to set a resource property that is not supported by the resource are ignored and are not considered errors.

    The order in which the resource values are set is not defined. If you need to guarantee the order in which resource values are set, you should make multiple requests to this method or setResourceValue:forKey:error:.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

  • Removes all cached resource values and temporary resource values from the URL object.

    Declaration

    Swift

    func removeAllCachedResourceValues()

    Objective-C

    - (void)removeAllCachedResourceValues

    Discussion

    This method is applicable only to URLs that represent file system resources.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 7.0 and later.

  • Removes the cached resource value identified by a given key from the URL object.

    Declaration

    Swift

    func removeCachedResourceValueForKey(_ key: String)

    Objective-C

    - (void)removeCachedResourceValueForKey:(NSString *)key

    Parameters

    key

    The resource value key whose cached values you want to remove.

    Discussion

    Removing a cached resource value may remove other cached resource values because some resource values are cached as a set of values, and because some resource values depend on other resource values. (Temporary resource values have no dependencies.)

    This method is currently applicable only to URLs for file system resources.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 7.0 and later.

  • Sets a temporary resource value on the URL object.

    Declaration

    Swift

    func setTemporaryResourceValue(_ value: AnyObject?, forKey key: String)

    Objective-C

    - (void)setTemporaryResourceValue:(id)value forKey:(NSString *)key

    Parameters

    value

    The value to store.

    key

    The key where the value should be stored. This key must be unique and must not conflict with any system-defined keys. Reverse-domain-name notation is recommended.

    Discussion

    Your app can use a temporary resource value to temporarily store a value for an app-defined resource value key in memory without modifying the actual resource that the URL represents. Once set, you can copy the temporary resource value from the URL object just as you would copy system-defined keys—by calling getResourceValue:forKey:error: or resourceValuesForKeys:error:.

    Your app can remove a temporary resource value from the URL object by calling removeCachedResourceValueForKey: or removeAllCachedResourceValues (to remove all temporary values).

    This method is applicable only to URLs for file system resources.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 7.0 and later.

Data Types

  • These schemes are the ones that NSURL can parse.

    Declaration

    Swift

    var NSURLFileScheme: NSString!

    Objective-C

    NSString * const NSURLFileScheme;

    Constants

    • NSURLFileScheme

      NSURLFileScheme

      Identifies a URL that points to a file on a mounted volume.

      Available in iOS 2.0 and later.

    Discussion

    For more information, see initWithScheme:host:path:.

  • Keys that apply to file system URLs.

    Declaration

    Swift

    let NSURLAddedToDirectoryDateKey: NSString! let NSURLAttributeModificationDateKey: NSString! let NSURLContentAccessDateKey: NSString! let NSURLContentModificationDateKey: NSString! let NSURLCreationDateKey: NSString! let NSURLCustomIconKey: NSString! let NSURLDocumentIdentifierKey: NSString! let NSURLEffectiveIconKey: NSString! let NSURLFileResourceIdentifierKey: NSString! let NSURLFileResourceTypeKey: NSString! let NSURLFileSecurityKey: NSString! let NSURLGenerationIdentifierKey: NSString! let NSURLHasHiddenExtensionKey: NSString! let NSURLIsDirectoryKey: NSString! let NSURLIsExcludedFromBackupKey: NSString! let NSURLIsExecutableKey: NSString! let NSURLIsHiddenKey: NSString! let NSURLIsMountTriggerKey: NSString! let NSURLIsPackageKey: NSString! let NSURLIsReadableKey: NSString! let NSURLIsRegularFileKey: NSString! let NSURLIsSymbolicLinkKey: NSString! let NSURLIsSystemImmutableKey: NSString! let NSURLIsUserImmutableKey: NSString! let NSURLIsVolumeKey: NSString! let NSURLIsWritableKey: NSString! let NSURLLabelColorKey: NSString! let NSURLLabelNumberKey: NSString! let NSURLLinkCountKey: NSString! let NSURLLocalizedLabelKey: NSString! let NSURLLocalizedNameKey: NSString! let NSURLLocalizedTypeDescriptionKey: NSString! let NSURLNameKey: NSString! let NSURLParentDirectoryURLKey: NSString! let NSURLPathKey: NSString! let NSURLPreferredIOBlockSizeKey: NSString! let NSURLThumbnailDictionaryKey: NSString! let NSURLTypeIdentifierKey: NSString! let NSURLVolumeIdentifierKey: NSString! let NSURLVolumeURLKey: NSString!

    Objective-C

    NSString * const NSURLAddedToDirectoryDateKey NSString * const NSURLAttributeModificationDateKey; NSString * const NSURLContentAccessDateKey; NSString * const NSURLContentModificationDateKey; NSString * const NSURLCreationDateKey; NSString * const NSURLCustomIconKey; NSString * const NSURLDocumentIdentifierKey NSString * const NSURLEffectiveIconKey; NSString * const NSURLFileResourceIdentifierKey; NSString * const NSURLFileResourceTypeKey; NSString * const NSURLFileSecurityKey; NSString * const NSURLGenerationIdentifierKey NSString * const NSURLHasHiddenExtensionKey; NSString * const NSURLIsDirectoryKey; NSString * const NSURLIsExcludedFromBackupKey; NSString * const NSURLIsExecutableKey; NSString * const NSURLIsHiddenKey; NSString * const NSURLIsMountTriggerKey; NSString * const NSURLIsPackageKey; NSString * const NSURLIsReadableKey; NSString * const NSURLIsRegularFileKey; NSString * const NSURLIsSymbolicLinkKey; NSString * const NSURLIsSystemImmutableKey; NSString * const NSURLIsUserImmutableKey; NSString * const NSURLIsVolumeKey; NSString * const NSURLIsWritableKey; NSString * const NSURLLabelColorKey; NSString * const NSURLLabelNumberKey; NSString * const NSURLLinkCountKey; NSString * const NSURLLocalizedLabelKey; NSString * const NSURLLocalizedNameKey; NSString * const NSURLLocalizedTypeDescriptionKey; NSString * const NSURLNameKey; NSString * const NSURLParentDirectoryURLKey; NSString * const NSURLPathKey NSString * const NSURLPreferredIOBlockSizeKey; NSString * const NSURLThumbnailDictionaryKey NSString * const NSURLTypeIdentifierKey; NSString * const NSURLVolumeIdentifierKey; NSString * const NSURLVolumeURLKey;

    Constants

    • NSURLAddedToDirectoryDateKey

      NSURLAddedToDirectoryDateKey

      The time at which the resource’s was created or renamed into or within its parent directory, returned as an NSDate. Inconsistent behavior may be observed when this attribute is requested on hard-linked items. This property is not supported by all volumes. (read-only)

      Available in OS X v10.10 and iOS 8.0.

    • NSURLAttributeModificationDateKey

      NSURLAttributeModificationDateKey

      The time at which the resource’s attributes were most recently modified, returned as an NSDate object if the volume supports attribute modification dates, or nil if attribute modification dates are unsupported (read-write).

      Available in iOS 4.0 and later.

    • NSURLContentAccessDateKey

      NSURLContentAccessDateKey

      The time at which the resource was most recently accessed, returned as an NSDate object if the volume supports access dates, or nil if access dates are unsupported (read-only).

      Available in iOS 4.0 and later.

    • NSURLContentModificationDateKey

      NSURLContentModificationDateKey

      The time at which the resource was most recently modified, returned as an NSDate object if the volume supports modification dates, or nil if modification dates are unsupported (read-write).

      Available in iOS 4.0 and later.

    • NSURLCreationDateKey

      NSURLCreationDateKey

      The resource’s creation date, returned as an NSDate object if the volume supports creation dates, or nil if creation dates are unsupported (read-write).

      Available in iOS 4.0 and later.

    • NSURLCustomIconKey

      NSURLCustomIconKey

      The icon stored with the resource, returned as an NSImage object, or nil if the resource has no custom icon.

      Not available in iOS; symbol is present, but performs no operation.

    • NSURLDocumentIdentifierKey

      NSURLDocumentIdentifierKey

      The document identifier returned as an NSNumber (read-only).

      The document identifier is a value assigned by the kernel to a file or directory. This value is used to identify the document regardless of where it is moved on a volume. The identifier persists across system restarts. It is not transferred when the file is copied, but it survives "safe save” operations. For example, it remains on the path to which it was assigned, even after calling the replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error: method. Document identifiers are only unique within a single volume. This property is not supported by all volumes.

      Available in OS X v10.10 and iOS 8.0.

    • NSURLEffectiveIconKey

      NSURLEffectiveIconKey

      The resource’s normal icon, returned as an NSImage object (read-only).

      Not available in iOS; symbol is present, but performs no operation.

    • NSURLFileResourceIdentifierKey

      NSURLFileResourceIdentifierKey

      The resource’s unique identifier, returned as an id (read-only).

      This identifier can be used to determine equality between file system resources with the isEqual: method. Two resources are equal if they have the same file-system path or if their paths link to the same inode on the same file system.

      The value of this identifier is not persistent across system restarts.

      Available in iOS 5.0 and later.

    • NSURLFileResourceTypeKey

      NSURLFileResourceTypeKey

      The resource’s object type, returned as an NSString object (read-only). See File Resource Types for possible values.

      Available in iOS 5.0 and later.

    • NSURLFileSecurityKey

      NSURLFileSecurityKey

      The resource’s security information, returned as an NSFileSecurity object (read-write).

      Available in iOS 5.0 and later.

    • NSURLGenerationIdentifierKey

      NSURLGenerationIdentifierKey

      An opaque generation identifier, returned as an id <NSCopying, NSCoding, NSObject> (read-only)

      The generation identifier can be compared using isEqual: to determine if the data in a document has been modified. For URLs which refer to the same file inode, the generation identifier changes when the data in the file's data fork is changed. Changes to extended attributes or other file system metadata do not change the identifier. For URLs which refer to the same directory inode, the generation identifier changes when direct children of that directory are added, removed or renamed. Changes to the data of the direct children of that directory does not change the generation identifier. The identifier persists across system restarts. It is tied to a specific document on a specific volume and is not transferred when the document is copied to another volume. This property is not supported by all volumes.

      Available in OS X v10.10 and iOS 8.0.

    • NSURLHasHiddenExtensionKey

      NSURLHasHiddenExtensionKey

      Key for determining whether the resource’s extension is normally removed from its localized name, returned as a Boolean NSNumber object (read-write).

      Available in iOS 4.0 and later.

    • NSURLIsDirectoryKey

      NSURLIsDirectoryKey

      Key for determining whether the resource is a directory, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLIsExcludedFromBackupKey

      NSURLIsExcludedFromBackupKey

      Key for determining whether the resource is excluded from all backups of app data, returned as a Boolean NSNumber object (read-write).

      You can use this property to exclude cache and other app support files which are not needed in a backup. Some operations commonly made to user documents cause this property to be reset to false; consequently, do not use this property on user documents.

      Available in iOS 5.1 and later.

    • NSURLIsExecutableKey

      NSURLIsExecutableKey

      Key for determining whether the current process (as determined by the EUID) can execute the resource (if it is a file) or search the resource (if it is a directory), returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLIsHiddenKey

      NSURLIsHiddenKey

      Key for determining whether the resource is normally not displayed to users, returned as a Boolean NSNumber object (read-write).

      Available in iOS 4.0 and later.

    • NSURLIsMountTriggerKey

      NSURLIsMountTriggerKey

      Key for determining whether the URL is a file system trigger directory, returned as a Boolean NSNumber object (read-only). Traversing or opening a file system trigger directory causes an attempt to mount a file system on the directory.

      Available in iOS 5.0 and later.

    • NSURLIsPackageKey

      NSURLIsPackageKey

      Key for determining whether the resource is a file package, returned as a Boolean NSNumber object (read-write in OS X v10.8 and later, read-only in previous versions). A true value means that the resource is a file package.

      If you attempt to set or clear this key’s value on a file instead of a directory, the system ignores your attempt. If the directory is defined as a package by way of its filename extension or other reason apart from this key, setting this key’s value to false has no effect.

      Available in iOS 4.0 and later.

    • NSURLIsReadableKey

      NSURLIsReadableKey

      Key for determining whether the current process (as determined by the EUID) can read the resource, returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLIsRegularFileKey

      NSURLIsRegularFileKey

      Key for determining whether the resource is a regular file, as opposed to a directory or a symbolic link. Returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLIsSymbolicLinkKey

      NSURLIsSymbolicLinkKey

      Key for determining whether the resource is a symbolic link, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLIsSystemImmutableKey

      NSURLIsSystemImmutableKey

      Key for determining whether the resource's system immutable bit is set, returned as a Boolean NSNumber object (read-write).

      Available in iOS 4.0 and later.

    • NSURLIsUserImmutableKey

      NSURLIsUserImmutableKey

      Key for determining whether the resource's user immutable bit is set, returned as a Boolean NSNumber object (read-write).

      Available in iOS 4.0 and later.

    • NSURLIsVolumeKey

      NSURLIsVolumeKey

      Key for determining whether the resource is the root directory of a volume, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLIsWritableKey

      NSURLIsWritableKey

      Key for determining whether the current process (as determined by the EUID) can write to the resource, returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLLabelColorKey

      NSURLLabelColorKey

      The resource’s label color, returned as an NSColor object, or nil if the resource has no label color (read-only).

      Not available in iOS; symbol is present, but performs no operation.

    • NSURLLabelNumberKey

      NSURLLabelNumberKey

      The resource’s label number, returned as an NSNumber object (read-write).

      Available in iOS 4.0 and later.

    • NSURLLinkCountKey

      NSURLLinkCountKey

      The number of hard links to the resource, returned as an NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLLocalizedLabelKey

      NSURLLocalizedLabelKey

      The resource’s localized label text, returned as an NSString object, or nil if the resource has no localized label text (read-only).

      Not available in iOS; symbol is present, but performs no operation.

    • NSURLLocalizedNameKey

      NSURLLocalizedNameKey

      The resource’s localized or extension-hidden name, returned as an NSString object (read-only).

      Available in iOS 4.0 and later.

    • NSURLLocalizedTypeDescriptionKey

      NSURLLocalizedTypeDescriptionKey

      The resource’s localized type description, returned as an NSString object (read-only).

      Available in iOS 4.0 and later.

    • NSURLNameKey

      NSURLNameKey

      The resource’s name in the file system, returned as an NSString object (read-write).

      Available in iOS 4.0 and later.

    • NSURLParentDirectoryURLKey

      NSURLParentDirectoryURLKey

      The parent directory of the resource, returned as an NSURL object, or nil if the resource is the root directory of its volume (read-only).

      Available in iOS 4.0 and later.

    • NSURLPathKey

      NSURLPathKey

      The file system path for the URL, returned as an NSString object (read-only).

      Available in iOS 6.0 and later.

    • NSURLPreferredIOBlockSizeKey

      NSURLPreferredIOBlockSizeKey

      The optimal block size to use when reading or writing this file's data, returned as an NSNumber object, or nil if the preferred size is not available (read-only).

      Available in iOS 5.0 and later.

    • NSURLThumbnailDictionaryKey

      NSURLThumbnailDictionaryKey

      A dictionary of NSImage/UIImage objects keyed by size (read-write). See Thumbnail Property Keys for a list of possible keys.

      Available in OS X v10.10 and iOS 8.0.

    • NSURLTypeIdentifierKey

      NSURLTypeIdentifierKey

      The resource’s uniform type identifier (UTI), returned as an NSString object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeIdentifierKey

      NSURLVolumeIdentifierKey

      The unique identifier of the resource’s volume, returned as an id (read-only).

      This identifier can be used with the isEqual: method to determine whether two file system resources are on the same volume.

      The value of this identifier is not persistent across system restarts.

      Available in iOS 5.0 and later.

    • NSURLVolumeURLKey

      NSURLVolumeURLKey

      The root directory of the resource’s volume, returned as an NSURL object (read-only).

      Available in iOS 4.0 and later.

    Discussion

    To request information using one of these keys, pass it to the forKey: parameter of the getResourceValue:forKey:error: instance method.

  • Possible values for the NSURLFileResourceTypeKey key.

    Declaration

    Swift

    let NSURLFileResourceTypeNamedPipe: NSString! let NSURLFileResourceTypeCharacterSpecial: NSString! let NSURLFileResourceTypeDirectory: NSString! let NSURLFileResourceTypeBlockSpecial: NSString! let NSURLFileResourceTypeRegular: NSString! let NSURLFileResourceTypeSymbolicLink: NSString! let NSURLFileResourceTypeSocket: NSString! let NSURLFileResourceTypeUnknown: NSString!

    Objective-C

    NSString * const NSURLFileResourceTypeNamedPipe; NSString * const NSURLFileResourceTypeCharacterSpecial; NSString * const NSURLFileResourceTypeDirectory; NSString * const NSURLFileResourceTypeBlockSpecial; NSString * const NSURLFileResourceTypeRegular; NSString * const NSURLFileResourceTypeSymbolicLink; NSString * const NSURLFileResourceTypeSocket; NSString * const NSURLFileResourceTypeUnknown;

    Constants

    • NSURLFileResourceTypeNamedPipe

      NSURLFileResourceTypeNamedPipe

      The resource is a named pipe.

      Available in iOS 5.0 and later.

    • NSURLFileResourceTypeCharacterSpecial

      NSURLFileResourceTypeCharacterSpecial

      The resource is a character special file.

      Available in iOS 5.0 and later.

    • NSURLFileResourceTypeDirectory

      NSURLFileResourceTypeDirectory

      The resource is a directory.

      Available in iOS 5.0 and later.

    • NSURLFileResourceTypeBlockSpecial

      NSURLFileResourceTypeBlockSpecial

      The resource is a block special file.

      Available in iOS 5.0 and later.

    • NSURLFileResourceTypeRegular

      NSURLFileResourceTypeRegular

      The resource is a regular file.

      Available in iOS 5.0 and later.

    • NSURLFileResourceTypeSymbolicLink

      NSURLFileResourceTypeSymbolicLink

      The resource is a symbolic link.

      Available in iOS 5.0 and later.

    • NSURLFileResourceTypeSocket

      NSURLFileResourceTypeSocket

      The resource is a socket.

      Available in iOS 5.0 and later.

    • NSURLFileResourceTypeUnknown

      NSURLFileResourceTypeUnknown

      The resource’s type is unknown.

      Available in iOS 5.0 and later.

  • Possible keys for the NSURLThumbnailDictionaryKey dictionary.

    Declaration

    Swift

    let NSThumbnail1024x1024SizeKey: NSString!

    Objective-C

    NSString * const NSThumbnail1024x1024SizeKey

    Constants

    • NSThumbnail1024x1024SizeKey

      NSThumbnail1024x1024SizeKey

      A 1024 x 1024 pixel thumbnail as a UIImage on iOS or an NSImage on OS X.

      Available in iOS 8.0 and later.

  • Keys that apply to properties of files.

    Declaration

    Swift

    let NSURLFileSizeKey: NSString! let NSURLFileAllocatedSizeKey: NSString! let NSURLTotalFileSizeKey: NSString! let NSURLTotalFileAllocatedSizeKey: NSString! let NSURLIsAliasFileKey: NSString!

    Objective-C

    NSString * const NSURLFileSizeKey; NSString * const NSURLFileAllocatedSizeKey; NSString * const NSURLIsAliasFileKey; NSString * const NSURLTotalFileAllocatedSizeKey; NSString * const NSURLTotalFileSizeKey;

    Constants

    • NSURLFileSizeKey

      NSURLFileSizeKey

      Key for the file’s size in bytes, returned as an NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLFileAllocatedSizeKey

      NSURLFileAllocatedSizeKey

      Key for the total size allocated on disk for the file, returned as an NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLTotalFileSizeKey

      NSURLTotalFileSizeKey

      Key for the total displayable size of the file in bytes, returned as an NSNumber object (read-only). This includes the size of any file metadata.

      Available in iOS 5.0 and later.

    • NSURLTotalFileAllocatedSizeKey

      NSURLTotalFileAllocatedSizeKey

      Key for the total allocated size of the file in bytes, returned as an NSNumber object (read-only). This includes the size of any file metadata.

      Available in iOS 5.0 and later.

    • NSURLIsAliasFileKey

      NSURLIsAliasFileKey

      Key for determining whether the file is an alias, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

  • Keys that apply to volumes.

    Declaration

    Swift

    let NSURLVolumeLocalizedFormatDescriptionKey: NSString! let NSURLVolumeTotalCapacityKey: NSString! let NSURLVolumeAvailableCapacityKey: NSString! let NSURLVolumeResourceCountKey: NSString! let NSURLVolumeSupportsPersistentIDsKey: NSString! let NSURLVolumeSupportsSymbolicLinksKey: NSString! let NSURLVolumeSupportsHardLinksKey: NSString! let NSURLVolumeSupportsJournalingKey: NSString! let NSURLVolumeIsJournalingKey: NSString! let NSURLVolumeSupportsSparseFilesKey: NSString! let NSURLVolumeSupportsZeroRunsKey: NSString! let NSURLVolumeSupportsCaseSensitiveNamesKey: NSString! let NSURLVolumeSupportsCasePreservedNamesKey: NSString! let NSURLVolumeSupportsRootDirectoryDatesKey: NSString! let NSURLVolumeSupportsVolumeSizesKey: NSString! let NSURLVolumeSupportsRenamingKey: NSString! let NSURLVolumeSupportsAdvisoryFileLockingKey: NSString! let NSURLVolumeSupportsExtendedSecurityKey: NSString! let NSURLVolumeIsBrowsableKey: NSString! let NSURLVolumeMaximumFileSizeKey: NSString! let NSURLVolumeIsEjectableKey: NSString! let NSURLVolumeIsRemovableKey: NSString! let NSURLVolumeIsInternalKey: NSString! let NSURLVolumeIsAutomountedKey: NSString! let NSURLVolumeIsLocalKey: NSString! let NSURLVolumeIsReadOnlyKey: NSString! let NSURLVolumeCreationDateKey: NSString! let NSURLVolumeURLForRemountingKey: NSString! let NSURLVolumeUUIDStringKey: NSString! let NSURLVolumeNameKey: NSString! let NSURLVolumeLocalizedNameKey: NSString!

    Objective-C

    NSString * const NSURLVolumeLocalizedFormatDescriptionKey; NSString * const NSURLVolumeTotalCapacityKey; NSString * const NSURLVolumeAvailableCapacityKey; NSString * const NSURLVolumeResourceCountKey; NSString * const NSURLVolumeSupportsPersistentIDsKey; NSString * const NSURLVolumeSupportsSymbolicLinksKey; NSString * const NSURLVolumeSupportsHardLinksKey; NSString * const NSURLVolumeSupportsJournalingKey; NSString * const NSURLVolumeIsJournalingKey; NSString * const NSURLVolumeSupportsSparseFilesKey; NSString * const NSURLVolumeSupportsZeroRunsKey; NSString * const NSURLVolumeSupportsCaseSensitiveNamesKey; NSString * const NSURLVolumeSupportsCasePreservedNamesKey; NSString * const NSURLVolumeSupportsRootDirectoryDatesKey; NSString * const NSURLVolumeSupportsVolumeSizesKey; NSString * const NSURLVolumeSupportsRenamingKey; NSString * const NSURLVolumeSupportsAdvisoryFileLockingKey; NSString * const NSURLVolumeSupportsExtendedSecurityKey; NSString * const NSURLVolumeIsBrowsableKey; NSString * const NSURLVolumeMaximumFileSizeKey; NSString * const NSURLVolumeIsEjectableKey; NSString * const NSURLVolumeIsRemovableKey; NSString * const NSURLVolumeIsInternalKey; NSString * const NSURLVolumeIsAutomountedKey; NSString * const NSURLVolumeIsLocalKey; NSString * const NSURLVolumeIsReadOnlyKey; NSString * const NSURLVolumeCreationDateKey; NSString * const NSURLVolumeURLForRemountingKey; NSString * const NSURLVolumeUUIDStringKey; NSString * const NSURLVolumeNameKey; NSString * const NSURLVolumeLocalizedNameKey;

    Constants

    • NSURLVolumeLocalizedFormatDescriptionKey

      NSURLVolumeLocalizedFormatDescriptionKey

      Key for the volume’s descriptive format name, returned as an NSString object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeTotalCapacityKey

      NSURLVolumeTotalCapacityKey

      Key for the volume’s capacity in bytes, returned as an NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeAvailableCapacityKey

      NSURLVolumeAvailableCapacityKey

      Key for the volume’s available capacity in bytes, returned as an NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeResourceCountKey

      NSURLVolumeResourceCountKey

      Key for the total number of resources on the volume, returned as an NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeSupportsPersistentIDsKey

      NSURLVolumeSupportsPersistentIDsKey

      Key for determining whether the volume supports persistent IDs, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeSupportsSymbolicLinksKey

      NSURLVolumeSupportsSymbolicLinksKey

      Key for determining whether the volume supports symbolic links, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeSupportsHardLinksKey

      NSURLVolumeSupportsHardLinksKey

      Key for determining whether the volume supports hard links, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeSupportsJournalingKey

      NSURLVolumeSupportsJournalingKey

      Key for determining whether the volume supports journaling, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeIsJournalingKey

      NSURLVolumeIsJournalingKey

      Key for determining whether the volume is currently journaling, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeSupportsSparseFilesKey

      NSURLVolumeSupportsSparseFilesKey

      Key for determining whether the volume supports sparse files, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeSupportsZeroRunsKey

      NSURLVolumeSupportsZeroRunsKey

      Key for determining whether the volume supports zero runs, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeSupportsCaseSensitiveNamesKey

      NSURLVolumeSupportsCaseSensitiveNamesKey

      Key for determining whether the volume supports case-sensitive names, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeSupportsCasePreservedNamesKey

      NSURLVolumeSupportsCasePreservedNamesKey

      Key for determining whether the volume supports case-preserved names, returned as a Boolean NSNumber object (read-only).

      Available in iOS 4.0 and later.

    • NSURLVolumeSupportsRootDirectoryDatesKey

      NSURLVolumeSupportsRootDirectoryDatesKey

      Key for determining whether the volume supports reliable storage of times for the root directory, returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeSupportsVolumeSizesKey

      NSURLVolumeSupportsVolumeSizesKey

      Key for determining whether the volume supports returning volume size information, returned as a Boolean NSNumber object (read-only). If true, volume size information is available as values of the NSURLVolumeTotalCapacityKey andNSURLVolumeAvailableCapacityKey keys.

      Available in iOS 5.0 and later.

    • NSURLVolumeSupportsRenamingKey

      NSURLVolumeSupportsRenamingKey

      Key for determining whether the volume can be renamed, returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeSupportsAdvisoryFileLockingKey

      NSURLVolumeSupportsAdvisoryFileLockingKey

      Key for determining whether the volume implements whole-file advisory locks in the style of flock, along with the O_EXLOCK and O_SHLOCK flags of the open function, returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeSupportsExtendedSecurityKey

      NSURLVolumeSupportsExtendedSecurityKey

      Key for determining whether the volume supports extended security (access control lists), returned as a Boolean NSNumber object (read-only) (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeIsBrowsableKey

      NSURLVolumeIsBrowsableKey

      Key for determining whether the volume is visible in GUI-based file-browsing environments, such as the Desktop or the Finder application, returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeMaximumFileSizeKey

      NSURLVolumeMaximumFileSizeKey

      Key for the largest file size supported by the volume in bytes, returned as a Boolean NSNumber object, or nil if it cannot be determined (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeIsEjectableKey

      NSURLVolumeIsEjectableKey

      Key for determining whether the volume is ejectable from the drive mechanism under software control, returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeIsRemovableKey

      NSURLVolumeIsRemovableKey

      Key for determining whether the volume is removable from the drive mechanism, returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeIsInternalKey

      NSURLVolumeIsInternalKey

      Key for determining whether the volume is connected to an internal bus, returned as a Boolean NSNumber object, or nil if it cannot be determined (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeIsAutomountedKey

      NSURLVolumeIsAutomountedKey

      Key for determining whether the volume is automounted, returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeIsLocalKey

      NSURLVolumeIsLocalKey

      Key for determining whether the volume is stored on a local device, returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeIsReadOnlyKey

      NSURLVolumeIsReadOnlyKey

      Key for determining whether the volume is read-only, returned as a Boolean NSNumber object (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeCreationDateKey

      NSURLVolumeCreationDateKey

      Key for the volume’s creation date, returned as an NSDate object, or NULL if it cannot be determined (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeURLForRemountingKey

      NSURLVolumeURLForRemountingKey

      Key for the URL needed to remount the network volume, returned as an NSURL object, or nil if a URL is not available (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeUUIDStringKey

      NSURLVolumeUUIDStringKey

      Key for the volume’s persistent UUID, returned as an NSString object, or nil if a persistent UUID is not available (read-only).

      Available in iOS 5.0 and later.

    • NSURLVolumeNameKey

      NSURLVolumeNameKey

      The name of the volume, returned as an NSString object (read-write). Settable only if NSURLVolumeSupportsRenamingKey is YEStrue.

      Available in iOS 5.0 and later.

    • NSURLVolumeLocalizedNameKey

      NSURLVolumeLocalizedNameKey

      The name of the volume as it should be displayed in the user interface, returned as an NSString object (read-only).

      Available in iOS 5.0 and later.

    Discussion

    As a convenience, volume resource property values can be requested from any file system URL. The value returned reflects the property value for the volume on which the resource is located.

  • Options used when creating bookmark data.

    Declaration

    Swift

    struct NSURLBookmarkCreationOptions : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var PreferFileIDResolution: NSURLBookmarkCreationOptions { get } static var MinimalBookmark: NSURLBookmarkCreationOptions { get } static var SuitableForBookmarkFile: NSURLBookmarkCreationOptions { get } static var WithSecurityScope: NSURLBookmarkCreationOptions { get } static var SecurityScopeAllowOnlyReadAccess: NSURLBookmarkCreationOptions { get } }

    Objective-C

    enum { NSURLBookmarkCreationPreferFileIDResolution = ( 1UL << 8 ), NSURLBookmarkCreationMinimalBookmark = ( 1UL << 9 ), NSURLBookmarkCreationSuitableForBookmarkFile = ( 1UL << 10 ), }; typedef NSUInteger NSURLBookmarkCreationOptions;

    Constants

    • PreferFileIDResolution

      NSURLBookmarkCreationPreferFileIDResolution

      Specifies that when a bookmark created with this option is resolved, its embedded file ID should take precedence over other sources of information (file system path, for example) in the event of a conflict.

      Available in iOS 4.0 and later.

      Deprecated in iOS 7.0.

    • MinimalBookmark

      NSURLBookmarkCreationMinimalBookmark

      Specifies that a bookmark created with this option should be created with minimal information. This produces a smaller bookmark that can be resolved in fewer ways.

      Available in iOS 4.0 and later.

    • SuitableForBookmarkFile

      NSURLBookmarkCreationSuitableForBookmarkFile

      Specifies that the bookmark data should include properties required to create Finder alias files.

      Available in iOS 4.0 and later.

    Discussion

    When creating a bookmark, use bitwise OR operators to combine the options you want to specify, and provide them to the options parameter of the bookmarkDataWithOptions:includingResourceValuesForKeys:relativeToURL:error: method.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

  • Options used when resolving bookmark data.

    Declaration

    Swift

    struct NSURLBookmarkResolutionOptions : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var WithoutUI: NSURLBookmarkResolutionOptions { get } static var WithoutMounting: NSURLBookmarkResolutionOptions { get } static var WithSecurityScope: NSURLBookmarkResolutionOptions { get } }

    Objective-C

    enum { NSURLBookmarkResolutionWithoutUI = ( 1UL << 8 ), NSURLBookmarkResolutionWithoutMounting = ( 1UL << 9 ), }; typedef NSUInteger NSURLBookmarkResolutionOptions;

    Constants

    • WithoutUI

      NSURLBookmarkResolutionWithoutUI

      Specifies that no UI feedback should accompany resolution of the bookmark data.

      Available in iOS 4.0 and later.

    • WithoutMounting

      NSURLBookmarkResolutionWithoutMounting

      Specifies that no volume should be mounted during resolution of the bookmark data.

      Available in iOS 4.0 and later.

    Discussion

    When resolving a bookmark, use bitwise OR operators to combine the options you want to specify, and provide them to the options parameter of the URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error: method.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later.

  • Keys in the userInfo dictionary of an NSError object when certain NSURL methods return an error.

    Declaration

    Swift

    let NSURLKeysOfUnsetValuesKey: NSString!

    Objective-C

    NSString * const NSURLKeysOfUnsetValuesKey;

    Constants

    • NSURLKeysOfUnsetValuesKey

      NSURLKeysOfUnsetValuesKey

      Key for the resource properties that have not been set after the setResourceValues:error: method returns an error, returned as an array of of NSString objects.

      Available in iOS 5.0 and later.

  • Keys that describe the iCloud storage state of a file.

    Declaration

    Swift

    let NSURLIsUbiquitousItemKey: NSString! let NSURLUbiquitousItemDownloadingErrorKey: NSString! let NSURLUbiquitousItemDownloadingStatusKey: NSString! let NSURLUbiquitousItemHasUnresolvedConflictsKey: NSString! let NSURLUbiquitousItemIsDownloadingKey: NSString! let NSURLUbiquitousItemIsUploadedKey: NSString! let NSURLUbiquitousItemIsUploadingKey: NSString! let NSURLUbiquitousItemUploadingErrorKey: NSString!

    Objective-C

    NSString * const NSURLIsUbiquitousItemKey; NSString * const NSURLUbiquitousItemDownloadingErrorKey; NSString * const NSURLUbiquitousItemDownloadingStatusKey; NSString * const NSURLUbiquitousItemHasUnresolvedConflictsKey; NSString * const NSURLUbiquitousItemIsDownloadedKey; NSString * const NSURLUbiquitousItemIsDownloadingKey; NSString * const NSURLUbiquitousItemIsUploadedKey; NSString * const NSURLUbiquitousItemIsUploadingKey; NSString * const NSURLUbiquitousItemPercentDownloadedKey; NSString * const NSURLUbiquitousItemPercentUploadedKey; NSString * const NSURLUbiquitousItemUploadingErrorKey;

    Constants

    • NSURLIsUbiquitousItemKey

      NSURLIsUbiquitousItemKey

      A boolean NSNumber that contains true if this item is in iCloud storage, false if it is a local item (read-only).

      Available in iOS 5.0 and later.

    • NSURLUbiquitousItemDownloadingErrorKey

      NSURLUbiquitousItemDownloadingErrorKey

      An error object that indicates why downloading the item from iCloud failed. See Foundation Constants Reference for possible error codes.

      Available in iOS 7.0 and later.

    • NSURLUbiquitousItemDownloadingStatusKey

      NSURLUbiquitousItemDownloadingStatusKey

      The current download state for the item, indicating whether a local copy exists and whether that copy is the most current version of the item. The possible values for this key are described in Ubiquitous Item Downloading Status Constants.

      Available in iOS 7.0 and later.

    • NSURLUbiquitousItemHasUnresolvedConflictsKey

      NSURLUbiquitousItemHasUnresolvedConflictsKey

      A boolean NSNumber that contains true if this item has conflicts outstanding, false otherwise (read-only).

      Available in iOS 5.0 and later.

    • NSURLUbiquitousItemIsDownloadedKey

      NSURLUbiquitousItemIsDownloadedKey

      A boolean NSNumber that contains true if this item’s data has been downloaded to a ubiquity container, false otherwise (read-only).

      Available in iOS 5.0 and later.

      Deprecated in iOS 7.0.

    • NSURLUbiquitousItemIsDownloadingKey

      NSURLUbiquitousItemIsDownloadingKey

      A boolean NSNumber that contains true if this item is being downloaded from iCloud, false otherwise (read-only).

      Available in iOS 5.0 and later.

    • NSURLUbiquitousItemIsUploadedKey

      NSURLUbiquitousItemIsUploadedKey

      A boolean NSNumber that contains true if this item’s data has been uploaded to iCloud storage, false otherwise (read-only).

      Available in iOS 5.0 and later.

    • NSURLUbiquitousItemIsUploadingKey

      NSURLUbiquitousItemIsUploadingKey

      A boolean NSNumber that contains true if this item is being uploaded to iCloud, false otherwise (read-only).

      Available in iOS 5.0 and later.

    • NSURLUbiquitousItemPercentDownloadedKey

      NSURLUbiquitousItemPercentDownloadedKey

      An NSNumber in the range 0–100 that indicates the percentage of the data that has been downloaded (read-only).

      Deprecated. Instead, use the property key NSMetadataUbiquitousItemPercentDownloadedKey of the NSMetadataQuery class to obtain information on an NSMetadataItem object.

      Available in iOS 5.0 and later.

      Deprecated in iOS 6.0.

    • NSURLUbiquitousItemPercentUploadedKey

      NSURLUbiquitousItemPercentUploadedKey

      An NSNumber in the range 0–100 that indicates the percentage of the data that has been uploaded (read-only).

      Deprecated. Instead, use the property key NSMetadataUbiquitousItemPercentUploadedKey of the NSMetadataQuery class to obtain information on an NSMetadataItem object.

      Available in iOS 5.0 and later.

      Deprecated in iOS 6.0.

    • NSURLUbiquitousItemUploadingErrorKey

      NSURLUbiquitousItemUploadingErrorKey

      An error object that indicates why uploading the item to iCloud failed. See Foundation Constants Reference for possible error codes.

      Available in iOS 7.0 and later.

    Discussion

    To request information about the iCloud storage state of an item, pass one of these keys to the forKey: parameter of the getResourceValue:forKey:error: instance method.

  • Values that describe the iCloud storage state of a file.

    Declaration

    Swift

    let NSURLUbiquitousItemDownloadingStatusCurrent: NSString! let NSURLUbiquitousItemDownloadingStatusDownloaded: NSString! let NSURLUbiquitousItemDownloadingStatusNotDownloaded: NSString!

    Objective-C

    NSString * const NSURLUbiquitousItemDownloadingStatusCurrent; NSString * const NSURLUbiquitousItemDownloadingStatusDownloaded; NSString * const NSURLUbiquitousItemDownloadingStatusNotDownloaded;

    Constants

    • NSURLUbiquitousItemDownloadingStatusCurrent

      NSURLUbiquitousItemDownloadingStatusCurrent

      A local copy of this item exists and is the most up-to-date version known to the device.

      Available in iOS 7.0 and later.

    • NSURLUbiquitousItemDownloadingStatusDownloaded

      NSURLUbiquitousItemDownloadingStatusDownloaded

      A local copy of this item exists, but it is stale. The most recent version will be downloaded as soon as possible.

      Available in iOS 7.0 and later.

    • NSURLUbiquitousItemDownloadingStatusNotDownloaded

      NSURLUbiquitousItemDownloadingStatusNotDownloaded

      This item has not been downloaded yet. Use startDownloadingUbiquitousItemAtURL:error: to download it.

      Available in iOS 7.0 and later.

    Discussion

    These constants are possible values for the NSURLUbiquitousItemDownloadingStatusKey key.