简体   繁体   中英

UIImage strings in iOS Database Sqlite

Ok, my application will have a set of buttons where each button will have its own UIImage and associated sound.

I am going to have a LOT of these buttons and am looking towards creating a sqlite 3 database which will be used to store the string location and sound location for each button.

That way I can add all the sounds and images into my project, and when i read from the database it will pull the images and sounds from my project folders based on its string location.

I have a number of questions:

1) is this the best way to go about doing this. Shall I store the actual buttons in my database instead? How to do this? 2) How to get the raw string location of UIImage and associated soundURL

If it were me, I'd give the image and the sound the same name, as in: giraffe.png giraffe.wav. You could put them in separate or the same directories depending on your preference. Then all you'd need is your list of names which could be in a flat file or a database if you need sorting/filtering capability.

There is no correct answer for the "best" way to do things. I always say if it works and it satisfies you, then it is the best way. That being said, storing large amounts of raw data in databases is usually frowned upon. Databases are great at tearing through large numbers of records...sorting them...filtering them...but not as good at returning large single objects.

As for the second question, you will need to be more precise. I assume you would store a button id, a URL to the image, and a URL to the sound. Then you can just initialize them with "initWithContentsOfURL"

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM