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.
Creating a new directory A new directory is created in Swift using the createDirectory(atPath:) instance method of the FileManager class. It is once again passing through the pathname of the new directory as an argument and returning a Boolean true or false result.
You can create a new group, with its own folder, directly in Xcode, but it's not at all obvious. Instead of choosing 'New Group', choose 'Add Files to “<Project>”'. Then, in the file picker dialog, click the New Folder button or press Command-Shift-N and type the name of the new folder/group.
In the iOS application we have to store files, images, audios, videos. We can do it by creating folder in Document directory. Document directory stores user data to the given path in the apps. You can read apps data from the path of document directory.
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)
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