JavaNut13 JavaNut13 - 2 months ago 18
Swift Question

Create Folder in Swift

I'm new to swift and I'm not sure how to make a new folder from a string path (or from some kind of

File/ NSFile
object)

This is on OS X with Cocoa.

Answer

My understanding is that you are trying to create a directory programmatically using swift. The code given below does the same.

    var err: NSErrorPointer = nil
    let manager = NSFileManager.defaultManager()
    manager.createDirectoryAtPath("/Users/abc/Desktop/swiftDir", withIntermediateDirectories: true, attributes: nil, error: err)
Comments