我正在尝试将数据插入到我创建的行中,但它只插入数据的最后一行。任何人都可以提出一种避免此错误的方法吗?对于cellForRowAtIndexPath
我的代码是:
NSInteger counter = [myArray count];
if (myArray.count > 0){
for (int i = indexPath.section; i<indexPath.section+1; i++){
for(int a = 0 ; a < counter; a++) {
NSDictionary *dic = [counterArray objectAtIndex:i];
NSString *dateString = [dic valueForKey:@"date"];
NSDictionary *dic2 = [myArray objectAtIndex:a];
NSString *dateString2 = [dic2 valueForKey:@"date"];
if ([dateString isEqualToString:dateString2]){
cell.bookTitle.text = [dic2 objectForKey:@"name"];
}
}
}
}
return cell;
}
到目前为止,它看起来像这样:
数组实际上是这样的:
(
{
BIBNo = 187883;
date = "13/08/2012";
itemSequence = 000010;
name = "Positive thinking / Susan Quilliam.";
noOfRenewal = 2;
number = 000187899;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 161816;
date = "14/08/2012";
itemSequence = 000010;
name = "Malaysian Q & As / compiled by Survey & Interview Department ; illustrations by Exodus.";
noOfRenewal = 0;
number = 000161817;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 187882;
date = "14/08/2012";
itemSequence = 000010;
name = "Increasing confidence / Philippa Davies.";
noOfRenewal = 0;
number = 000187907;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 291054;
date = "14/08/2012";
itemSequence = 000010;
name = "iPhone application development for IOS 4 / Duncan Campbell.";
noOfRenewal = 2;
number = 000291054;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 244441;
date = "15/08/2012";
itemSequence = 000010;
name = "Coach : lessons on the game of life / Michael Lewis.";
noOfRenewal = 1;
number = 000244441;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 290408;
date = "15/08/2012";
itemSequence = 000010;
name = "Sams teach yourself iPhone application development in 24 hours / John Ray.";
noOfRenewal = 3;
number = 000290408;
status = "Normal Loan";
time = "24:00";
type = Loans;
}
)