iphone - Sqlite + 80K rows + LIKE = keyboard lag -
I have a problem that I am resolving, but now is the time.
I have a basic dictionary program, it has a UISearchBar and a UITableView. This is due to the keyboard lag while running on the device except by the way it works. (The simulator is okay, of course) I have two types of searches: As-you-type and on-return I think that taking both of the same amount of time to return results, but as you type keyboard Make intervals of
I have a UISearchBar text dead change that takes search text and sends it to a search method, raises all the escalation, puts the result in an array, the table is reloaded.
- (zero) search bar: (UISearchBar *) Search Bert Text Did Change: (NSString *) search text {if ((search type == SEARCH_AS_YOU_TYPE) & amp; amp; ([[ Search text length] & gt; = 2)) {NSString * myKeyword = [NSString stringWithFormat: @ "% @", search text]; [Self search: myKeyword]; [MyTableViewReload Data]; }} I limit the results to 50. And I like the use of my SQL query and or, there is no way to it yet.
SELECT WORD_ID, DEFIN, PINYIN, SIMP, TRAD, where defined by DEFIN "% to dog%" or DEFIN such as "% dog" or DEFIN "% dog%" DEFIN LIMIT < / Code> I also tried to move [myTableView reloadData] into the search method, hopefully the keyboard will not have minimal interval. no joy. And unfortunately I know that SQLite is basically checking every line, when it uses the same operator but 3-4 seconds for 80 hours seem a bit slow.
Any thoughts, ideas, comments or suggestions will be highly appreciated!
I think that you are searching and preparing the keyboard in the same thread. The more times you search this way, the more you will have letters and typing speed will be limited to the speed of the search.
An appropriate solution is different in two threads, the second one to search and display search results to read one and display the keyboard. In this way, if you can search, you are typing fast, only the search interval, but not typing. For example, the Firefox address bar works like this.
Due to communication / coordination between the two threads and the two, your code will become more complex, but I think that this is the only good solution.
Comments
Post a Comment