Instance Method


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


- (BOOL)setResourceValue:(id)value forKey:(NSURLResourceKey)key error:(NSError * _Nullable *)error;



The value for the resource property defined by key.


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


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

Return Value

YES if the resource property named key is successfully set to value; otherwise, NO.


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 NO and populates the object pointer referenced by error with additional information.

See Also

Accessing Resource Values

- resourceValuesForKeys:error:

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

- getResourceValue:forKey:error:

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

- setResourceValues:error:

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

- removeAllCachedResourceValues

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

- removeCachedResourceValueForKey:

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

- setTemporaryResourceValue:forKey:

Sets a temporary resource value on the URL object.


Keys that apply to file system URLs.