I have a simple UITableView that I\'d like to populate using a plist file. I have followed a few tutorials but they all seem to over complicate the process and in the end I
To load the file :
thearray = [NSArray arrayWithContentsOfFile:thePath];
Then you need to set your controller as the data source and delegate for the table view and implement at least :
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [thearray count];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell* cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
// assuming your array contains only simple strings :
cell.textLabel.text = [thearray objectAtIndex:indexPath.row];
return cell;
}
This doesn't use the "reuse" of cells which is important if your list is big.