从我的Sqlite数据库中获取一个数组中的两个表数据
这个数组显示如下,
(
(
{
Name = A;
Date = "2012-03-13 00:00:00";
InvoiceNo = 1;
Zip = 58555;
type = sale;
},
{
Name = B;
Date = "2012-03-13 00:00:00";
InvoiceNo = 3;
Zip = 58556;
type = sale;
}
),
(
{
Name = C;
Date = "2012-03-13 00:00:00";
InvoiceNo = 10;
Zip = 58556;
type = Gift;
},
{
Name = D;
Date = "2012-03-13 00:00:00";
InvoiceNo = 6;
Zip = 58556;
type = Gift;
}
)
)
在“ cellForRowAtIndexPath ”代码
上 UILabel *ItemData = [[UILabel alloc]initWithFrame:CGRectMake(20,32,80,18)];
ItemData.text =[[Query objectAtIndex:indexPath.row]valueForKey:@"Name"];
[ItemData setFont:[UIFont boldSystemFontOfSize:16.0]];
[cell.contentView addSubview:ItemData];
[ItemData release];
我想将数据打印到Tableview中,因此需要传递“ValueforKey”,
但是无法处理它,它让应用程序崩溃了,
拜托,任何人都建议我,我该怎么做?
答案 0 :(得分:0)
你有一个包含数组的数组,包含字典,对吧? 因此,您需要在一个单独的数组中使用此代码:
[[MergedArray objectAtIndex:indexPath.row] valueForKey:@"Name"]
将正常运作。
答案 1 :(得分:0)
试试这个:
NSMutableArray *array =[[NSMutableArray alloc]init];
for (id *obj_1 in Query) {
for (id *obj_2 in obj_1) {
[array addObject:obj_2];
}
}
now in cellForRowAtIndexPath method
IteamData.text=[[array objectAtIndex:indexPath.row] valueForKey@"Name" ];