Reputation: 159
I would like to know about storing the images or files of my application to the device. I think we can store these things to Document directory/library. I would like to know , is there any other options we have.
I have seen somewhere like, we can save the images to photo library with UIImageWriteToSavedPhotosAlbum.Could anyone please give me more information regarding this.If it is saved to photo library where is it being saved ?
Upvotes: 0
Views: 318
Reputation: 1727
You certainly can save to the local user directory for the app, though keep in mind that this is sandboxed by iOS so that each app has its own document directory.
For example, here is code (Swift 3) to get a "Database Working Folder":
// The working folder for our DB. This will be in the user's document store!
var _dbWorkingFolder: String?
// We're just going to use the user's document folder
_dbWorkingFolder = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]
It is possible to use AppGroups to have 2 or more apps that you control share a single space. But keep in mind this AppGroup has to be engineered into all apps that use it!
Here is Apple's doc on the iOS file system
Here is Apple's doc on writing App Extensions which actually uses AppGroups to allow an extension and and App to share space.
Finally, yes there is full support for you to write to the Photo Library. You'll want to use the Photos Framework and the images and videos are simply saved into the iOS "Photos" app. You can create a folder to hold your App's images, for instance.
Here is a link to Apple's Photos Framework.
If you have more specific questions, be sure to post those along with code you've tried and you'll get lots of help here!
Upvotes: 1