Class

NSDirectoryEnumerator

An object that enumerates the contents of a directory.

Declaration

@interface NSDirectoryEnumerator<__covariant ObjectType> : NSEnumerator

Overview

You obtain a directory enumerator using NSFileManager’s enumeratorAtPath: method. The enumeration provides the pathnames of all files and directories contained within that directory. These pathnames are relative to the directory.

An enumeration is recursive, including the files of all subdirectories, and crosses device boundaries. An enumeration does not resolve symbolic links, or attempt to traverse symbolic links that point to directories.

Topics

Getting File and Directory Attributes

directoryAttributes

A dictionary with the attributes of the directory at which enumeration started.

fileAttributes

A dictionary with the attributes of the most recently returned file or subdirectory (as referenced by the pathname).

level

The number of levels deep the current object is in the directory hierarchy being enumerated.

Skipping Subdirectories

- skipDescendents

Causes the receiver to skip recursion into the most recently obtained subdirectory.

- skipDescendants

Causes the receiver to skip recursion into the most recently obtained subdirectory.

Relationships

Inherits From

See Also

Discovering Directory Contents

- contentsOfDirectoryAtURL:includingPropertiesForKeys:options:error:

Performs a shallow search of the specified directory and returns URLs for the contained items.

- contentsOfDirectoryAtPath:error:

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

- 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.

- enumeratorAtPath:

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

- mountedVolumeURLsIncludingResourceValuesForKeys:options:

Returns an array of URLs that identify the mounted volumes available on the device.

NSVolumeEnumerationOptions

Options for enumerating mounted volumes with the mountedVolumeURLsIncludingResourceValuesForKeys:options: method.

- subpathsOfDirectoryAtPath:error:

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

- subpathsAtPath:

Returns an array of strings identifying the paths for all items in the specified directory.