I have more than 10000+ record in database. I want to load it on a table view. It will take 3 to 4 seconds to fetch all data from database and than load it on table view. Is there is more efficient way to increase the response and load the data in a uitableview? Here is my code for get All Data fro database
- (void)getAllData {
NSString * convertInttoStr = [NSString stringWithFormat:@"%d", rowNumber];
// Getting the database path.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
NSString *dbPath = [docsPath stringByAppendingPathComponent:@"iandroidquran_database 3.sqlite"];
FMDatabase *database = [FMDatabase databaseWithPath:dbPath];
[database open];
NSString *sqlSelectQuery = [NSString stringWithFormat:
@"SELECT * FROM qSurahContent WHERE surahID=%@" ,
convertInttoStr];
// Query result
FMResultSet *resultsWithNameLocation = [database executeQuery:sqlSelectQuery];
while([resultsWithNameLocation next]) {
NSString *strID = [NSString stringWithFormat:@"%d",[resultsWithNameLocation intForColumn:@"surahID"]];
NSString *strName = [NSString stringWithFormat:@"%@",[resultsWithNameLocation stringForColumn:@"surahContentArabic"]];
NSLog(@"surahID = %@, surahName = %@",strID, strName);
[surahId addObject:strID];
[surahContentArabic addObject:strName];
}
[self.tblView reloadData];
[database close];
}
Any solution?? Thanks
Aucun commentaire:
Enregistrer un commentaire