Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

How to reference a table of data

Hi,

Can anyone tell me how I go about referencing a table of data within an app? I want to be able to do a look-up to a data table as part of a calculation and return the result to the screen. I have never done this before and it would be great to get some direction. I am not sure of the best way to format the data, store it, and reference it?

Thanks heaps, Alex

2 Answers

yes a database would work fine and is probably the best way to do this. Have a look at Parse.com. Parse allows you to create and use a database very easily. The Build A Self Destructing Message app course here covers using Parse.com as a backend. once you learn how to use and interact with Parse its very easy to work with. You can import csv files into your database which is nice if you already have all the data and just need to import it.

There is really no quick and easy solution, working with large amounts of data and managing it is not a beginner friendly concept, but Parse is probably the easiest way to do it.

Thanks Stone, I took your advice and used parse and it is working great. Thank you so much!

you could store the data as an NSArray of dictionaries and then use methods provided by NSArray or a for loop to look up what you need. you could store the NSArray as a property to your view controller and fill it with data in viewDidLoad. whenever you need to reference it you would just use self.theNameOfTheProperty

Hi Steve, thanks so much for your reply! Would I use the method you suggested even if the data table consists of 9 columns with 40 rows of data? I started trying to look at sqlite3 and setting up the table as a database, I have been following tutorials but I am finding it quite tricky, so would be great to know the easiest way to set this up! I am working on it at the moment and am a bit stuck!

Thanks again, Alex