I am attempting to return a NSDirectoryEnumerator object from the NSFileManager method enumeratorAtUrl. This results in a compiler error:
Cannot convert the expressions type 'NSDirectoryEnumerator!' to type 'NSDirectoryEnumeratorOptions'
let url:NSURL = NSURL(fileURLWithPath: "/")
var keys:Array<AnyObject> = [NSURLNameKey, NSURLIsDirectoryKey]
var manager:NSFileManager = NSFileManager.defaultManager()
let enumerator:NSDirectoryEnumerator = manager.enumeratorAtURL(url,includingPropertiesForKeys: keys, options: 0, errorHandler: nil)
This works in Obj-C but not Swift.. Has anyone else encountered this issue?
Try this:
let enumerator:NSDirectoryEnumerator = manager.enumeratorAtURL(url, includingPropertiesForKeys: keys, options: NSDirectoryEnumerationOptions(), errorHandler: nil)
Or in short, pass in NSDirectoryEnumerationOptions()
instead of "0
".
"0" is not really a member of the enumeration it is looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With