How do I iterate over the contents of a folder within the current working directory in Swift?
<p>New to Swift.</p>

<p>Having checked that a folder called <code>data</code> exists within the current working directory using this code:</p>

<pre><code>// Get the current working directory
let fileManager = FileManager()
let cwd = fileManager.currentDirectoryPath
var isDir: ObjCBool = false

if (fileManager.fileExists(atPath: cwd + "/data", isDirectory: &amp;isDir)){
    if (isDir.boolValue) {
        // There is a directory called `data`
    }
}
</code></pre>

<p>I cannot figure out how to iterate through the contents of the <code>data</code> folder. Specifically, I'm just trying to store the names of all top-level folders within the <code>data</code> folder. I've looked at the <code>FileManager.contentsOfDirectory(at:includingPropertiesForKeys:options:)</code> function but I think that takes a <code>URL</code> not a <code>String</code> and I don't know how to convert my path (<code>cwd</code>) to a <code>URL</code>.</p>

<p>The <code>fileManager.contentsOfDirectory(atPath:)</code> function does take a <code>String</code> but I don't think it returns an iteratable result.</p>

<p>Can anybody help?</p>