Insert data to tableview from array
I hope this isn't too basic to ask here but I'm stuck (again).
I have an array (populated from a sqlite db) and want to insert those data in an UITableView.
So basically I want my textfields and buttons, and of course my tableview to all reside in the same window. Most of the examples I find out there is about hardcoding the tableview and populating in the viewDidLoad, which I don't want to and therefore can't use those examples (or rather, they don't work)
This is what I got:
if (sqlite3_prepare_v2(dbHandle, query, -1, &statement, NULL) == SQLITE_OK ){
NSMutableArray *array = [[NSMutableArray alloc] init];
//step through the results
while (sqlite3_step(statement) == SQLITE_ROW) {
[array addObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)]];
//NSLog(@"Data: %@",[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)]);
}
dataArray = [array sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
[arr开发者_JAVA技巧ay release];
sqlite3_finalize(statement); //releases the resources associted with the statment
sqlite3_close(dbHandle); //close db
//***********here I want something like: "tableview.data = dataArray.data"*******
Do anyone have any example to point me to or write down here?
actually I have revised the problem... the population works after modification. But the problem that I seemed to have from the beginning (wich I thought was the root of the problem) is that the table fills up the whole window.
I read somewhere that I could make a subview... but wouldnt that make another window? can I make a subview within my current window (tableview on half that window)?
精彩评论