mamcx

unread,

Dec 24, 2009, 5:00:21 AM12/24/09

to Three20

I'm trying to understand how mix my Sqlite database with Three20.

My app is fairly simple. List of records & more complex detail views
for each type.

I have stored up to 20,000 records, so I need a way to load only the
necesary data, support searching (but not the actual way to search,
this kind of search is really filtering, I want something more like
Google: Search:Sample then hit ENTER then show results.)

So, I see the TTModel but wonder about how attack it? I don't want to
load all the data in CreateModel...

And is possible to add another state to table view? I need one that
say: Please search.

uprise78

unread,

Dec 24, 2009, 6:23:46 AM12/24/09

to Three20

You can follow the TTRemoteModel implemention and instead of using a
TTURLRequest you can perform your SQL queries. That should get you
started.

mamcx

unread,

Dec 24, 2009, 7:30:07 PM12/24/09

to Three20

I don't have a TTRemoteModel.

But if I understand this well, I must subclass TTModel, then sublcass
TTSectionedDataSource or TTListDataSource?

uprise78

unread,

Dec 24, 2009, 10:05:54 PM12/24/09

to Three20

TTRemoteModel is a Three20 class. What you want to do is mimic what
it is doing replacing the TTURLRequests with your SQL queries. One
simple way to do it is to use NSOperations for your SQL queries to
keep things async and have your NSOperation subclass call all the same
delegate functions that TTURLRequests do. With that in place your
models will all manage themselves and their tableviews automatically.

Cruz Marina Cortès Galeano

unread,

Dec 25, 2009, 6:51:51 PM12/25/09

to Three20

That will not work. Or at least, is very hard. Treadhing and sqlite
not work weel together:http://stackoverflow.com/questions/745565/how-
to-properly-call-sqlite-functions-from-background-thread-on-iphone

Also, in the current trunk of Three20 TTRemote not exist at all.

This is what I have (based on my Sqlite wrapper: http://code.google.com/p/chibiorm/:

TTSqliteModel : NSObject <TTModel, TTSqliteModel> with
- (void) loadData:(NSString *)sql inside a Array of dic data.

TTSqliteDataSource : TTListDataSource, that I don't know how not load
all data at first run.

Now I get the list of data and basic navigation. So far is working
nice enough and I think I will reduce something like 50% of my code
with the move to Three20.

But I wonder how start with the table empty so the user must search,
and return a Sectioned Table view with results. So, how load data on-
demand?

uprise78

unread,

Dec 25, 2009, 8:19:12 PM12/25/09

to Three20

On the contrary NSOperationQueue works fabulously with SQLite when you
set the max concurrent operations to 1. It couldn't be easier. As long
as all your database ops are through the NSOperationQueue everything
is handled for you.

On Dec 25, 9:51 am, Cruz Marina Cortès Galeano <cruzcor...@gmail.com>
wrote:

Reply all

Reply to author

Forward