Returns a directory enumerator object that can be used to perform a deep enumeration of the directory at the specified path.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
The path of the directory to enumerate.
NSDirectory object that enumerates the contents of the directory at
path is a filename, the method returns an enumerator object that enumerates no files—the first call to
next will return
Because the enumeration is deep—that is, it lists the contents of all subdirectories—this enumerator object is useful for performing actions that involve large file-system subtrees. This method does not resolve symbolic links encountered in the traversal process, nor does it recurse through them if they point to a directory.
This code fragment enumerates the subdirectories and files under a user’s
Documents directory and processes all files with an extension of
NSDirectory class has methods for obtaining the attributes of the existing path and of the parent directory and for skipping descendants of the existing path.