Instance Method

subpathsOfDirectoryAtPath:error:

Performs a deep enumeration of the specified directory and returns the paths of all of the contained subdirectories.

Declaration

- (NSArray<NSString *> *)subpathsOfDirectoryAtPath:(NSString *)path error:(NSError * _Nullable *)error;

Parameters

path

The path of the directory to list.

error

If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you do not want error information.

Return Value

An array of NSString objects, each of which contains the path of an item in the directory specified by path. If path is a symbolic link, this method traverses the link. This method returns nil if it cannot retrieve the device of the linked-to file.

Discussion

This method recurses the specified directory and its subdirectories. The method skips the “.” and “..” directories at each level of the recursion.

Because this method recurses the directory’s contents, you might not want to use it in performance-critical code. Instead, consider using the enumeratorAtURL:includingPropertiesForKeys:options:errorHandler: or enumeratorAtPath: method to enumerate the directory contents yourself. Doing so gives you more control over the retrieval of items and more opportunities to complete the enumeration or perform other tasks at the same time.

See Also

Related Symbols

- contentsOfDirectoryAtPath:error:

Performs a shallow search of the specified directory and returns the paths of any contained items.

- enumeratorAtPath:

Returns a directory enumerator object that can be used to perform a deep enumeration of the directory at the specified path.

- enumeratorAtURL:includingPropertiesForKeys:options:errorHandler:

Returns a directory enumerator object that can be used to perform a deep enumeration of the directory at the specified URL.