Ios 如何在自定义目录中创建文件夹,以及如何提前在/myapp/documents中创建文件夹(在构建应用程序时)?

Ios 如何在自定义目录中创建文件夹,以及如何提前在/myapp/documents中创建文件夹(在构建应用程序时)?,ios,swift,xcode,storyboard,Ios,Swift,Xcode,Storyboard,我正在为iOS和ipadOS制作一个词汇应用程序。结构是 文件夹(雅思、托福等)->词汇表(剑桥雅思、牛津雅思等)->单词(游戏、睡眠等) 词汇表文件将是.txt文件,所以我可以像 [“单词1”:“含义1”],[“单词1”,“含义2”] 我想在用户安装应用程序时将文件夹设置为文件 所以它将是我的应用程序/文档/文件夹 但当我安装应用程序时,它会变成我的应用程序/文档/,没有文件夹 是否有类似iOS上的安装脚本 第二个问题是我什么时候创建文件夹 let paths = NSSearchPathFo

我正在为iOS和ipadOS制作一个词汇应用程序。结构是

文件夹(雅思、托福等)->词汇表(剑桥雅思、牛津雅思等)->单词(游戏、睡眠等)

词汇表文件将是.txt文件,所以我可以像

[“单词1”:“含义1”],[“单词1”,“含义2”]

我想在用户安装应用程序时将文件夹设置为文件

所以它将是我的应用程序/文档/文件夹

但当我安装应用程序时,它会变成我的应用程序/文档/,没有文件夹

是否有类似iOS上的安装脚本

第二个问题是我什么时候创建文件夹

let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
let documentsDirectory = paths[0]
let docURL = URL(string: documentsDirectory)!
let dataPath = docURL.appendingPathComponent(String(AddNewFolder.text!)) // AddNewFolder is a Text Field
if !FileManager.default.fileExists(atPath: dataPath.absoluteString) {
    do {
        try FileManager.default.createDirectory(atPath: dataPath.absoluteString, withIntermediateDirectories: true, attributes: nil)
    } catch {
        print(error.localizedDescription);
    }
}
如何在myapp/documents/folders而不是/myapp/documents中创建新文件夹

第三个问题是关于UIKit和SwiftUI的。什么更快,什么更容易使用


在SwiftUI中,有SwiftUI应用程序和UIKit delegate,什么是UIKit delegate?(这是否意味着我在SwiftUI中使用UIKit?

我搜索了整整一周。答案是

// make subdirectory "vocabFolder" if it doesn't exist
let VocabFolderPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("vocabFolder")

if !FileManager.default.fileExists(atPath: VocabFolderPath.absoluteString) {
    try! FileManager.default.createDirectory(at: VocabFolderPath, withIntermediateDirectories: true, attributes: nil)
}
    
// create custom vocab folder
let CustomVocabFolderPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("vocabFolder/\(String(AddNewFolder.text!))")
    
if !FileManager.default.fileExists(atPath: CustomVocabFolderPath.absoluteString) {
    try! FileManager.default.createDirectory(at: CustomVocabFolderPath, withIntermediateDirectories: true, attributes: nil)
}
要导航Simualtor设备,请执行
open'xcrun simctl get_app_container booted BUNDLE_IDENTIFIER data'-a Finder

一个选项,用于在代码中创建文件夹。在应用程序启动时检查文件夹是否存在,否则创建它。如何查看整个目录?文件仅显示icloud和用户目录,而不显示应用程序、/etc、/usr、/var等。是否有一个应用程序可以导航整个文件系统?