Do you need to delete imported files from Documents/Inbox?

匿名 (未验证) 提交于 2019-12-03 02:56:01

问题:

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];

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

回答1:

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

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]; ...

Read the reference

From apple doc:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!