I've set up a SQLite DB that currently reads and writes NSString
s perfectly. I also want to store an image in the database and recall it later. I've read up a bit on using NSData
and encoding the image, but I'm not entirely sure what the syntax is for what I want to do. Any code snippets or examples would be greatly appreciated.
My current process goes like this:
UIImagePickerController
-> User Chooses Image from Photos -> chosenImage is set to instance of UIImageView
-> Now I want to take this image and store it in the DB
I should mention this call will eventually be replaced with a call to a remote server. Not sure if this makes a difference as far as performance goes.
One option (and generally preferred when working in SQL) is to write the image to a file on the system and store the path (or some other kind of identifier) in the database.