ios - 如何获取我的 iOS 应用程序的根目录?
问题描述
我能够访问我的 iOS 应用程序的当前用户的临时目录,并且我能够访问捆绑路径,如以下代码所示:
print(FileManager.default.temporaryDirectory)
print(Bundle.main.bundlePath)
如何访问当前用户的应用程序根目录?我需要根据此链接中文档中的说明创建缓存目录或 Documents 目录:
Xcode 的 beta 版本提供了一个可以访问主目录的属性,但最新版本的 Xcode 没有。
解决方案
let fileManager = FileManager.default
let pathOfDir = fileManager.currentDirectoryPath
print(pathOfDir)
这用于获取您的根目录
推荐阅读
- windows - Apache 服务拒绝在 Windows 服务小程序中启动
- ms-access - MS Access - 创建通用 Sub 以设置子窗体上的控件属性
- python - Pandas:带有填充空白的完全外连接
- python - 显示正方形而不是一些特殊字符 - Python PIL
- webflow - 我使用 CMS 功能在 webflow 中制作了一个收藏列表。然后我将背景图像添加到列表中,但是当我打印页面时它们没有显示?
- c++ - QT将2个文本框与一条线连接起来
- azure - 如何在 Program.cs 中检索 Azure 应用配置服务设置
- spring-boot - Spring Session 集成到 Spring Security - 如何填充身份验证
- firebase - 防止 firebase 函数始终更新 Node.js 10
- sql - 使用 VBA UDF 在 Access 数据库中生成自定义患者 ID