Skip to content

Instantly share code, notes, and snippets.

@tjw
Last active October 5, 2016 21:47
Show Gist options
  • Save tjw/c79ffd3d920ffad2fcd4ca7d751a73cb to your computer and use it in GitHub Desktop.
Save tjw/c79ffd3d920ffad2fcd4ca7d751a73cb to your computer and use it in GitHub Desktop.
import Foundation
let u = URL(fileURLWithPath: "/tmp/missing-path", isDirectory: true)
let d = FileManager.default.enumerator(at:u, includingPropertiesForKeys: nil, errorHandler: {_,_ in return false})!
print("d \(d)") // --> d <NSURLDirectoryEnumerator: 0x100a01940>
// Crashes, unless the error handler above is replaced with nil
for _ in d {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment