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-01-2009, 06:32 AM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 29
Bisbo is on a distinguished road
Default Best way to handle TableView data and SQLite

Hi there,

I want to display a list of items (sometimes more than 1000), and each list item will display several bits of data from a specific record on a SQLite database. I'm not quite sure how to go about it, as I could either:

a) retrieve the data directly from the SQLite database on every invoke of tableView:cellForRowAtIndexPath:

b) on the viewDidLoad: method of the table view controller, load all of the records into an array of objects holding just the information needed to display the cells.

I'm not sure which one is best because I'm not sure if method A will be too slow over time having to run queries every time a row needs queuing (especially if the user flicks the table view fast), and B may take up a lot of memory, especially when there is lots of data per row and thousands of rows.

One additional constraint is that I will eventually need to have a search box on the table view. Will this affect the decision?

I'm hoping that I could get some tips from anyone with more experience!

Many thanks,

Michael
Bisbo is offline   Reply With Quote
Old 05-01-2009, 07:29 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 98
XCHG is on a distinguished road
Default

UITableView is very inefficient for records more than 200-300. I have been there, believe me. Think of something else.
XCHG is offline   Reply With Quote
Old 05-06-2009, 07:40 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: New York
Posts: 44
rob345 is on a distinguished road
Default

Quote:
Originally Posted by XCHG View Post
UITableView is very inefficient for records more than 200-300. I have been there, believe me. Think of something else.
Can you tell me the solution you came up with for this problem??
Thanks.
rob345 is offline   Reply With Quote
Old 05-06-2009, 07:46 AM   #4 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 98
XCHG is on a distinguished road
Default

There is nothing much you can do. It's iPhone. You only have a few MB of physical memory to create the whole application. Consider for example using UIScrollView with UILabels put inside it as your cells.
XCHG is offline   Reply With Quote
Old 06-02-2009, 02:08 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 5
supermandt is on a distinguished road
Default iPhoneToot.com

Hi All,
What i do is create an array and store just the primary key of the records from your SELECT statement. Then, you basically have an integer array. What you do is on every cell, simply load the cell with the data from the primary key. I call a function that I pass in the primary key and it returns and object of the record so I can pick and choose which data I want to display. Since the array is only holding numbers, memory management is very good even with hundreds of records. Give it a try!

Dave
iPhoneToot.com



Quote:
Originally Posted by XCHG View Post
There is nothing much you can do. It's iPhone. You only have a few MB of physical memory to create the whole application. Consider for example using UIScrollView with UILabels put inside it as your cells.
supermandt is offline   Reply With Quote
Old 06-02-2010, 01:22 AM   #6 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 5
Niki is on a distinguished road
Default

Quote:
Originally Posted by supermandt View Post
Hi All,
What i do is create an array and store just the primary key of the records from your SELECT statement. Then, you basically have an integer array. What you do is on every cell, simply load the cell with the data from the primary key. I call a function that I pass in the primary key and it returns and object of the record so I can pick and choose which data I want to display. Since the array is only holding numbers, memory management is very good even with hundreds of records. Give it a try!

Dave
iPhoneToot.com
Thanks for your help.But I don't know how to invoke a method before viewDidLoad?I have written my select query code in one method.Please help me.
Thanks
Niki is offline   Reply With Quote
Old 09-13-2010, 05:06 AM   #7 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: UK, North East
Posts: 227
zardon is on a distinguished road
Default

Quote:
Originally Posted by Niki View Post
Thanks for your help.But I don't know how to invoke a method before viewDidLoad?I have written my select query code in one method.Please help me.
Thanks
Try viewWillLoad in the documentation, or put the select query code in a seperate file (.h and .m) and then load it when you need it, say in the appdelegate (I know, I know -- this is not advised)
zardon is offline   Reply With Quote
Reply

Bookmarks

Tags
sqlite, tableview, tableviewcontroller

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: 311
8 members and 303 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:03 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0