美文网首页
iOS App的各种路径获取

iOS App的各种路径获取

作者: iwasee | 来源:发表于2017-08-02 12:00 被阅读48次

    let bundlePath =Bundle.main.bundlePath

    let homeDir =NSHomeDirectory()

    let tmpDir =NSTemporaryDirectory()

    print("NSDocumentDirectory")

    if let docDir =FileManager.default.urls(for:FileManager.SearchPathDirectory.documentDirectory, in:FileManager.SearchPathDomainMask.userDomainMask).first{

    print(docDir)

    }

    print(NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory,FileManager.SearchPathDomainMask.userDomainMask,true))

    print("NSLibraryDirectory")

    if let libDir =FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first{

    print(libDir)

    }

    print(NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask,true).first??"Not Found")

    print("NSCachesDirectory")

    print(NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first??"Not Found")

    print("NSTemporaryDirectory")

    print(NSTemporaryDirectory())

    相关文章

      网友评论

          本文标题:iOS App的各种路径获取

          本文链接:https://www.haomeiwen.com/subject/bimelxtx.html