Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you need to delete imported files from 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];

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

like image 324
ngb Avatar asked Apr 25 '13 11:04

ngb


1 Answers

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.

like image 103
B.S. Avatar answered Nov 12 '22 09:11

B.S.