我正在从我的文档文件夹中加载一个 Plist,我有 7 条记录......检查下面:但我的主视图表只显示 5,这通过我的 "numberOfRowsInSection : return [accounts count] 得到确认......代码是下面,我是否在某处遗漏了什么……是否有设置:注意:数据是虚构的
Account = (
"BOA Mortgage",
"Citibank Visa",
HOA,
"Toyota Finance",
"CitiBank Account",
West,
"Wells Fargo"
);
Balance = (
"5678.00",
1099,
"145.00",
"21000.00",
"4500.00",
1200,
450
);
DayDue = (
8,
3,
6,
26,
5,
3,
23
);
MinAmount = (
"1899.00",
"1200.00",
"329.00",
"583.84",
"225.00",
45,
35
);
Number = (
"8837430-002",
"29932843-00",
45225028,
452308582345,
25390403232,
1234578,
1234566
);
}
- (void)viewDidLoad
{
NSLog(@"loading data");
self.navigationItem.title=@"Accounts";
// NSString *accountFile = [[NSBundle mainBundle] pathForResource:@"Accounts2" ofType:@"plist"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = [paths objectAtIndex:0];
NSString *plistPath = [documentPath stringByAppendingPathComponent:@"Accounts2.plist"];
accounts = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
NSLog(@"Accounts contains : %@", accounts);
account = [accounts objectForKey:@"Account"];
NSLog(@"account %@", account);
number = [accounts objectForKey:@"Number"];
dueDay = [accounts objectForKey:@"DayDue"];
minAmount = [accounts objectForKey:@"MinAmount"];
balance = [accounts objectForKey:@"Balance"];
NSLog(@"data loaded");
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)];
self.navigationItem.rightBarButtonItem = addButton;
}
这是我的 cellForRowAtIndexPath 中的更多代码......它也只返回 5
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
NSDate *object = _objects[indexPath.row];
cell.textLabel.text = [object description];
NSString *nameOfAccount = [account objectAtIndex:indexPath.row];
cell.textLabel.text = nameOfAccount;
NSString *accountNumber = [number objectAtIndex:indexPath.row];
cell.detailTextLabel.text = accountNumber;
NSLog(@"Index %d", indexPath.row);
return cell;
}