如何在iPhone的Files应用程序中显示我的应用程序文档 [英] How can I display my App documents in the Files app for iPhone

查看:42
本文介绍了如何在iPhone的Files应用程序中显示我的应用程序文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试在iPhone的Files应用程序中显示我的应用程序中的数据 我找了很多,每件事都做对了,我不知道哪里出了错

func fileManger(nameFolder: String) {

    let manager = FileManager.default
    let DecomentFolder = manager.urls(for: .documentDirectory, in: .userDomainMask).last
    let Folder = DecomentFolder?.appendingPathComponent("(nameFolder)")

    do {
        try manager.createDirectory(at: Folder!, withIntermediateDirectories: true, attributes: [:])
    } catch let error {
        print(error.localizedDescription)
    }
}

另外,我在这里发送要作为文件夹的值

@objc func alertNewFolder () {
    let alert = UIAlertController(title: "Create an album", message: "", preferredStyle: .alert)
    alert.addTextField(configurationHandler: nil)
    alert.textFields![0].placeholder = "name album"
    alert.textFields![0].textAlignment = .right
    alert.addAction(UIAlertAction(title: "cancel", style: .cancel, handler: nil))
    alert.addAction(UIAlertAction(title: "save", style: .default, handler: { ـ in
        if let textFileds = alert.textFields {
            let links = textFileds[0].text
            self.arrS1.append(addCatogrey(nameCatog: links!, imageSection: UIImage(named: "folder")))
// Here Send FileManager
            helperCoding().fileManger(nameFolder: links!)
            self.collection.reloadData()
        }
    }))
    self.present(alert, animated: true, completion: nil)
}

在模拟器中,它正确地保存在此处的Documents文件夹中

/Users/badrshammry/Library/Developer/CoreSimulator/Devices/7986A27F-7026-45E1-9073-78CCD6A9B90A/data/Containers/Data/Application/3173C4DC-BCDE-41B9-89E1-6E8D9B52EF25/Documents

推荐答案

如果您想要在Apple的Files App中公开您的应用程序文档文件,您需要在您的info plist文件中包含<[2 0 0-0]>键并将其设置为YES:

enter image description here

这篇关于如何在iPhone的Files应用程序中显示我的应用程序文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆