Попробуйте это:
.m
#import "plistTableViewController.h"
#import "DetailViewController.h"
@interface plistTableViewController ()
@end
@implementation plistTableViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
NSString *mylist = [[NSBundle mainBundle] pathForResource:@"lodges" ofType:@"plist"];
tabledata = [[NSArray alloc]initWithContentsOfFile:mylist];
NSLog(@"%@", tabledata);
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [tabledata count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if( cell == nil )
{
NSLog(@"Cell Creation");
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];
}
//Set Data For each Cell
cell.textLabel.text = [[tabledata objectAtIndex:indexPath.row]objectForKey:@"cellName"];
cell.detailTextLabel.text = [[tabledata objectAtIndex:indexPath.row]objectForKey:@"cellSubtitle"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
.h
#import <UIKit/UIKit.h>
@interface plistTableViewController : UITableViewController
{
NSArray *tabledata;
}
@end
мой список имен называется lodges.plist, просто измените информацию по мере необходимости, и она будет работать. Я также добавил субтитры для вас.