On Nov 15, 2013, at 3:37 PM, Devarshi Kulshreshtha 
<devarshi.bluec...@gmail.com> wrote:

> In my iPhone app, I am downloading files from server and storing them
> locally (user's document directory).

That’s probably going to get a red flag from Apple when they review the app. 
They are pretty strict about enforcing that only user-created data goes into 
Documents. If it’s downloaded data that could be re-loaded if needed, that 
should go into the Caches directory so it won’t take up backup space in the 
user’s iCloud account.

> Now my question is - suppose user downloaded 20000 files, say small images,
> and user turned on the switch to delete all data on app exit. Is it good to
> handle this task in applicationWillTerminate?

Probably not. That only gets called when the OS decides to terminate the app 
process to free up memory, _not_ when the user leaves the app. If you want to 
delete stuff when the user exits the app, you should do that in 
-applicationDidEnterBackground:.

As for the deletion, I don’t know how long deleting 20,000 files will take; 
you’d need to experiment. The OS only gives your process a limited amount of 
time to respond to the enter-background (or terminate) notification before 
killing the process, but I don’t know exactly how long that is.

Another option, if the files really are small, is to store the file contents 
directly in the database. Then all you have to delete is the database file 
itself. (This will also save disk space, because the file system allocates 
files in 4k chunks, so with 20,000 files you could be wasting as much as 80MB.) 
This isn’t a good idea for larger files, though, because SQLite isn’t efficient 
at handling big blobs.

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to