Storyboard を使用する iPhone アプリケーションを開発しています。最初のシーンには、Table View Controller があります。会社という名前のプロパティ ファイルがあり、そのファイルの値を読み込んで UITableView に表示しようとしています。私は何時間もこれに取り組んできましたが、役に立ちませんでした。この質問は近づいてきましたが、その答えも役に立ちませんでした。
プロパティ ファイルの形式は次のとおりです。
これが私のコードです。
CompaniesTableViewController.mファイル
#import "CompaniesTableViewController.h"
@interface CompaniesTableViewController ()
@end
@implementation CompaniesTableViewController
NSMutableArray *companies;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *companiesFile = [[NSBundle mainBundle]pathForResource:@"companies" ofType:@"plist"];
companies = [[NSMutableArray alloc]initWithContentsOfFile:companiesFile];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [companies count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text = [[companies objectAtIndex:indexPath.row]objectForKey:@"Value"];
return cell;
}
テーブル ビューにはデータが取り込まれません。私が見落としているもの、ここで欠けているものを誰か教えてもらえますか?