Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-02-2009, 03:12 PM   #1 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
Join Date: Jan 2009
Location: California
Posts: 40
dougdrury is on a distinguished road
Default help with sqlite & sectioned (grouped) tables...

I have an sqlite db with two tables: 'states' and 'cities'

Code:
states
-------------
stateID (int pk)
stateName (varchar)

cities
-------------
cityID ( int pk)
cityName (varchar)
I know how to load a single database table into a tableview, but I now need to load my sql query results into a grouped table that would look something like this:
http://www.netsoftservices.com/groupedlist.jpg

I am just using static arrays to get the picture to look right.

Can anyone point me in the right direction to a tutorial or thread on this very thing? I have searched this site using most of the keywords I can think of and find nothing.

Any help would be appreciated!!

Thanks,
Doug
dougdrury is offline   Reply With Quote
Old 05-10-2009, 11:14 AM   #2 (permalink)
New Member
 
Join Date: Nov 2008
Posts: 39
velkropie is on a distinguished road
Wink

Quote:
Originally Posted by dougdrury View Post
I have an sqlite db with two tables: 'states' and 'cities'

Code:
states
-------------
stateID (int pk)
stateName (varchar)

cities
-------------
cityID ( int pk)
cityName (varchar)
I know how to load a single database table into a tableview, but I now need to load my sql query results into a grouped table that would look something like this:
http://www.netsoftservices.com/groupedlist.jpg

I am just using static arrays to get the picture to look right.

Can anyone point me in the right direction to a tutorial or thread on this very thing? I have searched this site using most of the keywords I can think of and find nothing.

Any help would be appreciated!!

Thanks,
Doug
check out the sqlite books tutorial in apple web dev!!!
velkropie is offline   Reply With Quote
Old 05-10-2009, 12:40 PM   #3 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
Join Date: Jan 2009
Location: California
Posts: 40
dougdrury is on a distinguished road
Default

velkropie,
I used the books tut to learn the sqlite stuff, but there was no grouped table used in that tut. I ended up creating city objects and stuffed them into a states array. Then iterated through both sets of arrays to build the grouped table.

Thanks for your reply though. Seems like replies are getting slower here on this board. People must have gotten busy rewriting their apps for 3.0.

Thanks again.
dougdrury is offline   Reply With Quote
Old 05-10-2009, 03:01 PM   #4 (permalink)
New Member
 
Join Date: Nov 2008
Posts: 39
velkropie is on a distinguished road
Default

Quote:
Originally Posted by dougdrury View Post
velkropie,
I used the books tut to learn the sqlite stuff, but there was no grouped table used in that tut. I ended up creating city objects and stuffed them into a states array. Then iterated through both sets of arrays to build the grouped table.

Thanks for your reply though. Seems like replies are getting slower here on this board. People must have gotten busy rewriting their apps for 3.0.

Thanks again.
well, they looked grouped to me. it looks like they were sectioned and the views looked group, i'm the expert at iphone...so, maybe i'm missing the definition of grouped tables...
velkropie is offline   Reply With Quote
Old 10-14-2009, 10:58 AM   #5 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 9
aimos is on a distinguished road
Default

Hi dougdrury,
How did you solved? I too am interested..

Thanks!!
aimos is offline   Reply With Quote
Old 10-14-2009, 12:07 PM   #6 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
Join Date: Jan 2009
Location: California
Posts: 40
dougdrury is on a distinguished road
Default

Quote:
Originally Posted by aimos View Post
Hi dougdrury,
How did you solved? I too am interested..

Thanks!!
aimos,
The code is a bit too long to post, but here is the steps I took.

I created two NSMutableArrays (sections, cities)

in the ViewDidLoad statement:
I loaded my states table into the sections array via an SQL query.
I then iterated through that sections array and did SQL queries on my cities table to load only the cities that matched that section into a temp cities array and stuffed that into the sections array as a sub item for that index.

Then I reloaded my table using the sections array with numberOfRowsInSection based on the cities count for that section.

Hope that helps some.

Doug
dougdrury is offline   Reply With Quote
Old 10-14-2009, 02:24 PM   #7 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 9
aimos is on a distinguished road
Default

Hi Doug,
thanks for reply..
Unfortunately are beginning and earn about different books..
My database is based on this tutorial:
iPhone SDK Tutorial: Reading data from a SQLite Database | dBlog.com.au
I can not understand what you mean, is not an example(source) that you or I can send via email the code needed? My email: aemus77@gmail.com
Please help me, many days that is still in my application..
Sorry for my bad English

Many thanks!
aimos is offline   Reply With Quote
Old 10-16-2009, 03:37 AM   #8 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 9
aimos is on a distinguished road
Default

Help me .., I have 2 tables and I can not see data in my Tableview..
For weeks we try ..

Thanks
aimos is offline   Reply With Quote
Old 09-13-2010, 05:14 AM   #9 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: UK, North East
Posts: 227
zardon is on a distinguished road
Default

Quote:
Originally Posted by dougdrury View Post
aimos,
The code is a bit too long to post, but here is the steps I took.

I created two NSMutableArrays (sections, cities)

in the ViewDidLoad statement:
I loaded my states table into the sections array via an SQL query.
I then iterated through that sections array and did SQL queries on my cities table to load only the cities that matched that section into a temp cities array and stuffed that into the sections array as a sub item for that index.

Then I reloaded my table using the sections array with numberOfRowsInSection based on the cities count for that section.

Hope that helps some.

Doug
So, let me see if I get you.

1. SELECT * from `states`
2. Populate a `sections` array with the results of 1.
3. Start For loop on sections array.
4. for each {section_Array as key}, grab the key do a select query on cities and display to the screen?
5. numberOfRowsInSection = cities count for section? -- How did you do this?

I've read some sites talk about using NSDictionaries to break up multi-join tables; is this how you do it?
5.
zardon is offline   Reply With Quote
Reply

Bookmarks

Tags
database, grouped, sqlite, tableview, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 312
8 members and 304 guests
blueorb, givensur, guusleijsten, jbro, mer10, n00b, SLIC, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:04 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0