您是否需要从Documents / Inbox中删除导入的文件? [英] Do you need to delete imported files from Documents/Inbox?

查看:836
本文介绍了您是否需要从Documents / Inbox中删除导入的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从电子邮件附件导入文件的iOS应用程序。
我注意到,一旦我完成它,它会将导入的文件放入Documents / Inbox。

I've got an iOS app that imported files from an email attachment. I've noticed that once i'm finished with it it places the imported file into Documents/Inbox.

我的应用程序是否应删除这些文件或是操作系统最终还是要清除它们吗?

Should my app be deleting these files or does the OS eventually get around to clearing them out?

如果是这样,怎么样?我试过了:

if so, how? i've tried:

[[NSFileManager defaultManager] removeItemAtPath:[self.url path] error:nil];

然而它似乎没有引用收件箱中的文件,即使self.url是我的导入文件的正确路径。

However it doesn't seem to reference the file in the inbox, even though self.url is the correct path to my import file.

推荐答案

系统不会清除导入的文件,因此您应该在必要时手动清除它们,但不要删除Documents目录。

System does not clear imported files, so you should clear them manually when it is necessary, but not to delete the Documents directory.

如何清除 NSDocumentsDirectory 你可以找到 这里

How to clear the NSDocumentsDirectory you can find here

如果你想从收件箱中删除文件,请使用相同的代码添加

If you want to delete files from the inbox use the same code adding

...
NSString *path = [NSString stringWithFormat:@"%@/Inbox", documentsDirectory ];
NSArray *directoryContents = [fileMgr contentsOfDirectoryAtPath:error:&error];
...

阅读 reference

来自apple doc:

From apple doc:


使用此目录可以访问
外部实体要求您打开应用程序的文件。具体来说,Mail程序会在此目录中放置与您的应用程序关联的电子邮件
附件; document
交互控制器也可以在其中放置文件。

Use this directory to access files that your app was asked to open by outside entities. Specifically, the Mail program places email attachments associated with your app in this directory; document interaction controllers may also place files in it.

您的应用程序可以读取和删除此目录中的文件,但无法创建新文件或写入现有文件。如果用户尝试在此目录中编辑
a文件,则在进行任何更改之前,您的应用必须以静默方式将其移出
目录。

Your app can read and delete files in this directory but cannot create new files or write to existing files. If the user tries to edit a file in this directory, your app must silently move it out of the directory before making any changes.

此目录的内容由iTunes备份。

The contents of this directory are backed up by iTunes.

这篇关于您是否需要从Documents / Inbox中删除导入的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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