Instance Method


Determines the type of relationship that exists between a system directory and the specified item.


- (BOOL)getRelationship:(NSURLRelationship *)outRelationship ofDirectory:(NSSearchPathDirectory)directory inDomain:(NSSearchPathDomainMask)domainMask toItemAtURL:(NSURL *)url error:(NSError * _Nullable *)error;



A pointer to a variable in which to put the relationship between directoryURL and otherURL. For a list of possible values, see NSURLRelationship.


The search path directory. For a list of possible values, see NSSearchPathDirectory.


The file system domain to search. Specify 0 for this parameter if you want the file manager to choose the domain that is most appropriate for the specified url.


The URL of the file or directory whose relationship to directoryURL is being tested. This parameter must not be nil.


On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return Value

YES if the relationship between the items was successfully determined, or NO if an error occurred.


Use this method to determine the relationship between an item and one of the system-specific directories. For example, you might use this method to determine if the specified item is in the user’s Documents directory or is in the trash. If the relationship between the items is determined successfully, this method sets the value of the outRelationship parameter to an appropriate value and returns YES. The directory may contain the item, it may be the same as the item, or it may not have a direct relationship to the item.