A
A
Alexander2015-07-24 11:28:00
Objective-C
Alexander, 2015-07-24 11:28:00

How to pass data from sqlite database to UITableViewController?

Good afternoon!
The task is to rewrite the application from Android to iOS. I'm having a hard time mastering enemy technologies :)
It is necessary to display data in a UITableViewController from a Sqlite database. All the examples that I have found load the entire table into memory:

items = [[NSMutableArray alloc] init];
…………
while (sqlite3_step(statement) == SQLITE_ROW) {
  …………
  [items addObject:obj];
}

Maybe I don’t understand, but Android has CursorAdapter (analogous to UITableViewController) and Cursor - a caching add-on over the result of executing an sql query.
No matter how much data there would be, only N records are stored in the cursor. Indeed, for viewing not on a phone, in general, you will not see more than 10 records ..... The
question is how to transfer data from the sqlite database to the UITableViewController not entirely, but using buffering?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
An, 2015-07-24
@Flanker_4

in sql query use offset and limit and thus load page by page.
Uploaded 20 records. If the user has scrolled to 15, shift offset by 20 , load the "next page"
Optionally unload the previous one (maybe look towards didReceiveMemmoryWarning)

S
Sunset_over, 2015-07-28
@Sunset_over

this is a sql query setting, or you can get 10 records from a page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question