Re: SQLite and TableView
Re: SQLite and TableView
- Subject: Re: SQLite and TableView
- From: Andreas Mayer <email@hidden>
- Date: Tue, 15 Jul 2003 01:12:43 +0200
Am Dienstag, 15.07.03 um 00:44 Uhr schrieb Sanri Parov:
1) How to populate in the simplest way the table?
Use the
- (SQLRow*)rowAtIndex:(int)inIndex;
method of SQLresult and
- (NSString*)stringForColumn:(NSString*)inColumnName;
from SQLRow.
2) Must I transform the return query values to an NSMutableArray?
No.
3) When and how must I redraw the TableView? As far as it's into a
drawer, before or after the drawer is opened?
You don't. The NSTableView draws itself when necessary. If you want the
table view to inform of a change in your data source, use -
(void)reloadData
In case want to force a redraw anyway use -
(void)setNeedsDisplay:(BOOL)flag
Let's say my database is very simple: the records are 'name' and 'age'
You could set the corresponding table column identifiers to "name" and
"age" in Interface Builder and do something like this:
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
NSString *result = nil;
SQLRow *row = [yourSQLResult rowAtIndex:rowIndex];
if (row) {
result = [row stringForColumn:[aTableColumn identifier]];
}
return result;
}
Hope this helps.
bye. Andreas.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.