I'm converting the Haneke Cacheing framework to Swift 3 and I've run into a snag with enumerateContentsOfDirectoryAtPath.
Here's the original syntax (view on github),
let fileManager = NSFileManager.defaultManager()
let cachePath = self.path
fileManager.enumerateContentsOfDirectoryAtPath(cachePath, orderedByProperty: NSURLContentModificationDateKey, ascending: true) { (URL : NSURL, _, inout stop : Bool) -> Void in
if let path = URL.path {
self.removeFileAtPath(path)
stop = self.size <= self.capacity
}
}
I believe what I'm looking for is the following function which I found by looking at the FileManger definition, however I don't know how to make the conversion:
public func enumerator(atPath path: String) -> FileManager.DirectoryEnumerator?
Question
What's the Swift 3 equivalent of enumerateContentsOfDirectoryAtPath and how should I use it while converting the above example?
enumerateContensOfDirectoryAtPathis an extension defined by the Haneke framework available here. It's not a standard method forNSFileManager. You need to translate that extension to Swift 3 first:Usage: