I've got an SQLite table that I need to get the data from, and output the data into a table. Here's what I got so far:
Database Manager (also handles connections, not shown):
- (NSArray *)clientsAll
{
[db open];
NSString *sql =
@"SELECT id, name, category, subcategories, icon, iconx2, pic, picx2, excerpt, score, pricetag, price "
@"FROM clients "
@"ORDER BY name ASC ";
FMResultSet *rs = [db executeQuery:sql];
NSMutableArray *rsMutArr = [[NSMutableArray alloc] init];
while ([rs next]) {
SQLClient *client = [[SQLClient alloc] init];
client.cid = [rs intForColumn:@"id"];
client.name = [rs stringForColumn:@"name"];
client.category = [rs stringForColumn:@"category"];
client.subcategories = [rs stringForColumn:@"subcategories"];
[rsMutArr addObject:client];
}
NSArray *rsArr = [NSArray arrayWithArray:rsMutArr];
[db close];
return rsArr;
}
Here's my @implementation listAllController
:
NSArray *clientsArray;
DatabaseManager *dbmgr;
My viewDidLoad
:
dbmgr = [[DatabaseManager alloc] init];
clientsArray = [dbmgr clientsAll];
My numberOfRowsInSection
:
return clientsArray.count;
And finally, my cellForRowAtIndexPath
:
static NSString *CellIndentifier = @"merchantCell";
SQLClient *client;
client = [clientsArray objectAtIndex:indexPath.item];
ListAllMerchantsCell *cell = [merchantNameTable dequeueReusableCellWithIdentifier:CellIndentifier];
cell.merchantNameLabel.text = client.name;
return cell;
Where the table cell has the cell identifier "merchantCell", and has a label "merchantNameLabel".
Problem is, all that gives me is a blank table. I've checked the SQL query using sqlitebrowser, and it does return what I asked. Is there anything else I could've missed?
I'm no pro at this, so I apologize in advance. If there's anything I can do to help (such as uploading more codes, etc.), please let me know.
Thanks.
Aucun commentaire:
Enregistrer un commentaire