sqlite - iPhone + sqlite3 + fmdb, What code do i need to put data into a UiTableView datasource? -


if adding data array uitableview datasource array i'd use this, in viewdidload.

nsmutablearray *array = [[nsarray alloc] initwithobjects:@"head first design patterns", @"head first html & css", @"head first iphone", nil]; self.transactionsarray = array; [array release]; 

and in cellforrowatindexpath

nsinteger row = [indexpath row]; cell.textlabel.text = [transactionsarray objectatindex:row]; 

but want link results select query, i'm using fmdb access database. heres how output data console fmdb @ moment.

fmdatabase* db = [fmdatabase databasewithpath:@"/tmp/mydb.db"]; if (![db open]) {     nslog(@"could not open db."); }  fmresultset *rs = [db executequery:@"select * mytable",  nil]; while ([rs next]) {     nslog(@"%@, %@, %@, %@, %@", [rs stringforcolumn:@"pid"],             [rs stringforcolumn:@"desc"],              [rs stringforcolumn:@"due"],             [rs stringforcolumn:@"price"],             [rs stringforcolumn:@"accumulated_price"]); } [rs close];  [db close]; 

how do ?

build transaction array in while loop this:

[transactionarray addobject:[nsdictionary dictionarywithobjectsandkeys:[rs stringforcolumn@"pid", @"dictionarylabel",........, nil]; 

edit: yup thats right, accesses use:

desclabelintableview = [[arraytmp objectatindex:indexpath.row] objectforkey:@"desc"]; 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -