gpt4 book ai didi

iphone - 您需要从文档/收件箱中删除导入的文件吗?

转载 作者:技术小花猫 更新时间:2023-10-29 10:50:06 28 4
gpt4 key购买 nike

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

我的应用应该删除这些文件还是操作系统最终会清除它们?

如果是,怎么办?我试过:

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

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

最佳答案

系统不会清除导入的文件,需要时请手动清除,但不要删除Documents目录。

如何清除NSDocumentsDirectory 你可以找到 here

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

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

阅读reference

来自苹果文档:

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.

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.

The contents of this directory are backed up by iTunes.

关于iphone - 您需要从文档/收件箱中删除导入的文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16213226/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com