For the past 2 weeks I have been reading and learning on how to create an iPhone App using these books: Beginning iOS 6 development, Storyboarding, and Using and Learning Objective C. I have been going through tutorials online and through these books but haven't been able to find what I am looking for.
I am creating a simple app that is a list of animals which would be searchable, and then when you click on the individual animal it shows information about it (name, picture, weight, and native location). I would like to be able to search via the common name or its species, and the user be able to select the animal and read the information about it. There is no adding new animals or editing the list. Next I would like to be able to also sort by continent. So for example the first Scene would have Animal as one cell and Continents in the other. If they click Animals, it pulls up all the animals and has a UISearchbar to search through all the animals, which they can proceed to click on. If they click continent (Australia), it would populate a searchable list only in that location.
My question is: How would I create a database that links these variables together, and then be able to search via the search bar (plist, core data, sqlite)? What resource should I use for a learning tool or tutorial?
The best choice depends on the amount and complexity of the data. If you only have a few hundred animals with a few attributes per animal then putting all of the data in a plist and loading all of the data into memory is fine.
If you have more data with large notes and other attributes, then you may not be able to load all of the data into memory. Then using SQLite would be a better option.
Core data is another option but it has the biggest learning curve and may be overkill for such simple data. Core data would be a good choice is the data was not read-only, if you had more relationships, and you wanted to sync the user data across devices.
It is good that you are reading all those things. I will try to create a "dumbed down" answer for you.
You ask about a database. This means for you where do I store the data. Apple and most technical people talk about this with the words Persistence or where do I persist the data.
The three commonly used (but I am sure not exclusive) methods of storage is:
(1) in a text file known as a plist file
(2) in a text file in xml format and
(3) in a sqlite file or database file
How do I access this data?
You are then going to hear about CoreData, CoreData was introduced by Apple to make it easier to access your stored data and also to help the small devices deal with large amounts of data. Accesing a Sqlite database without coredata needs a bit of work, but because of CoreData they make this easier.
As for the xml and plist, these can be accessed by simply reading the file into an Array or Dictionary and then you either search for or show data from those objects as you normally do.
(one thing about the sqlite/core data idea is that when setting up CoreData you can set up a sqlite data base or it can be in xml format.)
Once you know these two things, then you can mix and match based on what is needed for your purpose. If you have a large amount of data and do a lot with it then a sqilte file with CoreData access is going to be a good choice. If it is a very small amount of information then you can use a simple plist file and use a Array or Dictionary object to get the information, use it and then store it again in the file.
In your case it does sound like a simple plist would work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With