Skip to content

Commit 25dcc03

Browse files
author
Itai Ferber
committed
Add FileManager @escaping comment for clarification
1 parent 4702bde commit 25dcc03

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Foundation/NSFileManager.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,8 @@ open class FileManager : NSObject {
576576

577577
If you wish to only receive the URLs and no other attributes, then pass '0' for 'options' and an empty NSArray ('[NSArray array]') for 'keys'. If you wish to have the property caches of the vended URLs pre-populated with a default set of attributes, then pass '0' for 'options' and 'nil' for 'keys'.
578578
*/
579-
open func enumerator(at url: URL, includingPropertiesForKeys keys: [URLResourceKey]?, options mask: DirectoryEnumerationOptions = [], errorHandler handler: ((URL, Error) -> Bool)? = nil) -> DirectoryEnumerator? {
579+
// Note: Because the error handler is an optional block, the compiler treats it as @escaping by default. If that behavior changes, the @escaping will need to be added back.
580+
open func enumerator(at url: URL, includingPropertiesForKeys keys: [URLResourceKey]?, options mask: DirectoryEnumerationOptions = [], errorHandler handler: (/* @escaping */ (URL, Error) -> Bool)? = nil) -> DirectoryEnumerator? {
580581
if mask.contains(.skipsPackageDescendants) || mask.contains(.skipsHiddenFiles) {
581582
NSUnimplemented("Enumeration options not yet implemented")
582583
}
@@ -963,7 +964,8 @@ extension FileManager {
963964
var _rootError : NSError? = nil
964965
var _gotRoot : Bool = false
965966

966-
init(url: URL, options: FileManager.DirectoryEnumerationOptions, errorHandler: ((URL, NSError) -> Bool)?) {
967+
// See @escaping comments above.
968+
init(url: URL, options: FileManager.DirectoryEnumerationOptions, errorHandler: (/* @escaping */ (URL, NSError) -> Bool)?) {
967969
_url = url
968970
_options = options
969971
_errorHandler = errorHandler

0 commit comments

Comments
 (0)