<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFURLEnumeratorCreateForDirectoryURL(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFURLEnumeratorCreateForDirectoryURL"
  },
  "title" : "CFURLEnumeratorCreateForDirectoryURL(_:_:_:_:)"
}
-->

# CFURLEnumeratorCreateForDirectoryURL(_:_:_:_:)

Creates and returns a directory enumerator with provided enumerator behavior options and properties to be prefetched.

```
func CFURLEnumeratorCreateForDirectoryURL(_ alloc: CFAllocator!, _ directoryURL: CFURL!, _ option: CFURLEnumeratorOptions, _ propertyKeys: CFArray!) -> CFURLEnumerator!
```

## Parameters

`alloc`

The memory allocator to use. If `NULL`, the default allocator is used.

`directoryURL`

The URL of the directory to enumerate.

`option`

A bit array of enumerator behavior options.

`propertyKeys`

An array of file property keys to prefetch for each enumerated URL. Can be `NULL`.

## Return Value

The created directory enumerator.

## Discussion

Directory enumerators do not descend into subdirectories of `directoryURL` by default. To create a recursive enumerator, include the [`descendRecursively`](/documentation/CoreFoundation/CFURLEnumeratorOptions/descendRecursively) option in `options`.

Specifying prefetch properties allows the enumerator to optimize device access by using bulk operations. However, you should not prefetch properties that are not needed, because doing so may degrade performance.

The created directory enumerator generates URLs with the same type as `directoryURL`. If `directoryURL` is a file reference URL, then enumerated URLs are file reference URLs. If `directoryURL` is a file path URL, then enumerated URLs are file path URLs.

In some areas of the file system hierarchy, file reference URLs cannot be generated. The enumerator always generates file path URLs for these areas.

This function ignores the [`generateFileReferenceURLs`](/documentation/CoreFoundation/CFURLEnumeratorOptions/generateFileReferenceURLs) option.

## See Also

[`CFURLEnumeratorOptions`](/documentation/CoreFoundation/CFURLEnumeratorOptions)

Options for controlling enumerator behavior.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)