Using NSFileManager and createDirectoryAtPath in Swift

前端 未结 4 1463
伪装坚强ぢ
伪装坚强ぢ 2021-01-19 02:04

I\'m trying to create a new folder, but I can\'t figure out how to use createDirectoryAtPath correctly.

According to the documentation, this is the correct syntax:

4条回答
  •  清歌不尽
    2021-01-19 02:54

    The Swift 2.0 way:

    do {
        var deliverablePathString = "/tmp/asdf"
        try NSFileManager.defaultManager().createDirectoryAtPath(deliverablePathString, withIntermediateDirectories: false, attributes: nil)
    } catch let error as NSError {
        NSLog("\(error.localizedDescription)")
    }
    

提交回复
热议问题