I am using FMDB
, and i need to have a Database with the FirstName
, and Photo
of Students
. So the name of the databaase
will be Students, and the Attributes will be FirstName
and Photo
.
I know how to create
, and Insert
values to the database. But i don't know how to add images to the database.
I did a research and found out some ways that this could be implemented;
1.) Using BLOB
- most of the people in forums has discouraged it (I don't know why) 2.) To save the path of the images
If i am saving images using BLOB
then how can i do it ?
If i am saving the path of the images then how should i do it. Should i add all the images in the resource folder and then what should i do ?
NOTE: If i add several hundreds of images to the Resource folder in xCode what will the path of the file be ?
You should add your images to the Resources, but you should still save the image name in the database. This way, when you ask the database for the photo of the student, you will get the file name which you can use to get the photo from the application bundle:
// say your database returned 'student_45_photo.png'
NSString* imagePath = [[NSBundle mainBundle] pathForResource:@"student_45_photo" ofType:@"png"];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.