Using NSFileManager and createDirectoryAtPath in Swift

前端 未结 4 1415
伪装坚强ぢ
伪装坚强ぢ 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 03:09

    createDirectoryAtPath expects a String for the first parameter, not a URL. Try passing your path directly or use the URL-friendly variant createDirectoryForURL.

    Here is an example:

    NSFileManager.defaultManager().createDirectoryAtPath("/tmp/fnord", withIntermediateDirectories: false, attributes: nil, error: nil)

提交回复
热议问题