NSDirectoryEnumerator Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in iOS 2.0 and later.
Companion guide
Low-Level File Management Programming Topics
Declared in
NSFileManager.h

Overview

An NSDirectoryEnumerator object enumerates the contents of a directory, returning the pathnames of all files and directories contained within that directory. These pathnames are relative to the directory.

You obtain a directory enumerator using NSFileManager’s enumeratorAtPath: method. For more details, see Low-Level File Management Programming Topics.

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.

Tasks

Getting File and Directory Attributes

Skipping Subdirectories

Instance Methods

directoryAttributes

Returns an NSDictionary object that contains the attributes of the directory at which enumeration started.

- (NSDictionary *)directoryAttributes
Return Value

An NSDictionary object that contains the attributes of the directory at which enumeration started.

Discussion

See the description of the fileAttributesAtPath:traverseLink: method of NSFileManager for details on obtaining the attributes from the dictionary.

Availability
  • Available in iOS 2.0 and later.
See Also
Declared In
NSFileManager.h

fileAttributes

Returns an object that contains the attributes of the most recently returned file or subdirectory (as referenced by the pathname).

- (NSDictionary *)fileAttributes
Return Value

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

Discussion

See the description of the fileAttributesAtPath:traverseLink: method of NSFileManager for details on obtaining the attributes from the dictionary.

Availability
  • Available in iOS 2.0 and later.
Declared In
NSFileManager.h

level

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

- (NSUInteger)level
Return Value

The number of levels, with the directory passed to enumeratorAtURL:includingPropertiesForKeys:options:errorHandler: (NSFileManager) considered to be level 0.

Availability
  • Available in iOS 4.0 and later.
Declared In
NSFileManager.h

skipDescendants

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

- (void)skipDescendants
Discussion

This method is identical to skipDescendents except for the spelling.

Availability
  • Available in iOS 4.0 and later.
Declared In
NSFileManager.h

skipDescendents

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

- (void)skipDescendents
Availability
  • Available in iOS 2.0 and later.
Declared In
NSFileManager.h