Reputation: 31073
I want to save multipel photos in my application, so that application run in background. So what is the main difference between saving photos in doc dir or temp path.
And suggest me which is best way to save photos
NSUserDefaults
Thanks in advance
Upvotes: 2
Views: 2287
Reputation: 2593
Here is a reference: File System Programming Guide.
Temp folder:
Use this directory to write temporary files that do not need to persist between launches of your app. Your app should remove files from this directory when it determines they are no longer needed. (The system may also purge lingering files from this directory when your app is not running.)
Documents folder:
Use this directory to store critical user documents and app data files. Critical data is any data that cannot be recreated by your app, such as user-generated content.
Usually, I put files in temporary folder only when I cache something and I don't care if these files will be deleted. If I want to be sure these files should live long life, I put them to documents folder.
Upvotes: 4
Reputation:
The main difference is the path: <sandbox>/Documents
or <sandbox>/tmp
.
Some more differences:
The Documents
directory can be accessed via iTunes if your app has file sharing enabled.
The contents of the tmp
directory is volatile, the OS is free to purge it in order to save space.
About NSUserDefaults
: that's something completely different, it's a mechanism which stores app-specific configuration data in property lists, I can't imagine how and/or why you would use it for storing images.
Upvotes: 2