Instance Method

promisedItemResourceValuesForKeys:error:

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

Declaration

- (NSDictionary<NSURLResourceKey, id> *)promisedItemResourceValuesForKeys:(NSArray<NSURLResourceKey> *)keys error:(NSError * _Nullable *)error;

Parameters

keys

An array of names of URL resource properties.

error

The error that occurred in the case that one or more resource values cannot be retrieved.

Return Value

A dictionary of resource values indexed by key.

Discussion

This method behaves identically to resourceValuesForKeys:error:, but works on promised items. A promised item is not guaranteed to have its contents in the file system until you use a file coordinator to perform a coordinated read on its URL, which causes the contents to be downloaded or otherwise generated. Promised item URLs are returned by various APIs, including:

You must use this method instead of resourceValuesForKeys:error: for any URLs returned by these methods.

This method works for any resource value that is not tied to the item’s contents. Some keys, like NSURLContentAccessDateKey or NSURLGenerationIdentifierKey, do not return valid values. If you use one of these keys, the method returns YES, but the value returns nil.

See Also

Working with Promised Items

- checkPromisedItemIsReachableAndReturnError:

Returns whether the promised item can be reached.

- getPromisedItemResourceValue:forKey:error:

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