从扩展名读取和写入iOS应用程序文档文件夹 [英] reading and writing to an iOS application document folder from extension

查看:78
本文介绍了从扩展名读取和写入iOS应用程序文档文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发具有动作扩展的Objective-C iOS应用程序.加载操作扩展后,我需要从主机应用程序的documents目录中读取一些文件,然后将文件写入主机应用程序的document目录中.我已经创建了一个应用程序组,该应用程序和扩展名都设置了该应用程序组.但是,设置完后,我仍然不知道如何从扩展名的主机应用程序文档文件夹中读取和写入文件.有什么想法吗?

I am developing an objective-c iOS application that has an action extension. When the action extension loads I need to read some files from the documents directory of the host application and then write a file to the host applications document directory. I have created an application group and both the application and the extension have that application group set. But, after setting it I still not figure out how to read and write the files from the host applications document folder from the extension. Any ideas?

谢谢

乔什

推荐答案

您不能直接写入主机应用程序本身.应用程序组使您可以访问可通过iOS应用程序和扩展程序访问的共享文件系统容器.

You cannot write to the host application itself directly. Application Group gives you access to shared filesystem container accessible by both iOS app and Extension.

要获取该共享文件系统根文件夹的URL,请使用以下调用:

To get URL of that shared filesystem root folder, use this call:

FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.something")

这篇关于从扩展名读取和写入iOS应用程序文档文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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