mercredi 27 mai 2015

SQLite Tables to Grid in swift

I have three tables in an sqlite database.

Table 1 ID - FirstName - SecondName

Table 2 ID - Achievement Details

Table 3 Table1_ID - Table2_ID - Count

What i want to achieve is the following in a grid collection view

                       Achievement1   Achievement2  Achievement 3 etc   
FirstName SecondName    Count
FirstName SecondName    Count
FirstName SecondName    Count
etc

The actual grid I've got it works however issue i have is how to get the data from the tables into a usable form.

Atm i create a NSMutableArray which is full of arrays. An array for each row.

I then take table1 and put each result in the first entry of each array. I then take table2 and put it in the first array.

I then have to go though table3 putting each result into the relevant array entry. (Takes ages to search them all).

I just can't think of another way of doing it?. is their a more efficient way i can take data out the database?

Thanks

Aucun commentaire:

Enregistrer un commentaire