How can I save images to iphone directory and retrieve it? - iphone

I want to save image in iphone album and retrieve them on particular index, how can I?
I have to save profile of many people, along with their images, so how can I access such concept?

Do not save images in iPhone album if they're your application related only.
The better way is to create directory in your application documents directory and store them there. Or even better, do use CoreData and transient property to store image on your disk to keep your data well organized.

you also have choice to save the image in sqlite3 database and retrieve it when needed.

Related

Swift 5 Save AVAsset to UserDefaults

Users can scroll through the feed and retrieve videos from my cloud storage.
I would like to cache the videos (which I do successfully temporary in an array) but I want to retrieve the videos also when restarting the App.
Currently, if the user kills the app and starts again the temporary folder is of course empty.
How can I achieve that?
You need to persist the assets. There are several technologies for this, such as files in the user directory, CoreData, SQLite, etc. UserDefaults would not be recommended for such large files.

What is the best approch to save images and xml file in device (sqliteDB)

I am creating an iPhone application in which i have to store images and xml files locally in device (sqliteDB). So my question is what is the best way to do this?
I have two approaches in my mind.
1) Store images and xml in device and just save references of them in to sqliteDB.
2) Encode images and xml file to Base64 and save to sqliteDB directly.
Which will be more wise and why?
Do anyone have any other way to perform this by which application can run smoothly.
you can store both xml and images in (sqllite) i think it is best because we can perform CRUD operations .
Saving and retrieving images to and from SQLite in iOS
you can find how to save images in sqllite
http://mobile.tutsplus.com/tutorials/iphone/iphone-sdk_store-data/
above tutorial is about how to use sqllite in ios and save data in sqllite ,saving all these
data in sqllite is a wise way to manage the resources ..

Best way to store images in iOS

I was wondering if anyone could suggest the best way for me to store images for my app.
I want to be able to provide an XML update functionality that will allow the user to update their app with a new set of images. I was wondering what the best way to do this was as i need to read and write to the store location. Is storing them in a sqlite database the best way or am i able to use the filesystem to do this without the chance of the iPhone deleting any of the downloaded images?
Thanks
You can write to the filesystem, every app in iOS is sandboxed and has access to his own documents folder.
I would suggest to write on filesystem and only save the urls on the database as that is more performant than saving blobs on a database.
Apple has a good write up about the iOS filesystem.
Alternatively you could implement a solution using SQLite, Apple mentions it in the: Large Data Objects (BLOBs) section here:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdPerformance.html#//apple_ref/doc/uid/TP40003468-SW5

iOS how to manage photos

I'm creating an iOS app that works with photos.
I have built apps that do similar things on Android, and know of some of the pains that images can bring with regard to storage and memory management.
Here are my questions:
How do I save a picture that I've taken & where do I save it to (is it sensible to save it with core data somehow?)?
How do I load a picture from wherever I've saved it to?
For a tableview with images, do I need some form of lazy loading (you do on Android), if so, can anybody recommend a tutorial or library?
How do I save a picture that I've taken & where do I save it to (is it sensible to save it with core data somehow?)?
Use the system imagepicker/taker UIImagePickerController and no dont store images in CoreData. As a general rule store them in the system photo library. Store the Asset Library URL as a reference.
Images can be stored in your App documents folder also.
How do I load a picture from wherever I've saved it to?
Use the API in the AssetsLibrary framework to retrieve pictures from the system store.
For a tableview with images, do I need some form of lazy loading (you do on Android), if so, can anybody recommend a tutorial or library?
No. Lazy loading is done for free by your UITableViewController implementation. There are a 1001 great UITableView tutorials on the web.

How to save a large (60mb+) image to photo library?

I know the various ways to save a UIImage to the photo library:
UIImageWriteToSavedPhotosAlbum
ALAssetsLibrary
However, my images are HUGE (60mb+), so bringing them into memory is not possible. I can download the images by streaming them to disk, and even use imageWithContentsOfFile to take a peek (although that is kind of unnecessary given screen size).
But I want the user to be able to save these images for later. Is there anyway for me to get these large images into the photo library? Do I just have to keep them stored locally inside the app sandbox?
I believe that there is no point at storing them at the photo library, since it is designed to be viewed on the device and theres no point at viewing an image so big. If you want to let the user see the image then i suggest you create a preview and save THAT version into the photo library. If you want to let the user transfer them from the device to the computer there is a special folder in your app bundle which will allow those pictures to appear when using itunes and selecting your application. then he can transfer those pictures to his computer. Also could you elaborate on the characteristics of the images? format, dimentions, purpose, etc.