1
ここに私の問題です、私はセルに私のplistの名前を表示することができるUITableViewを作成しようとしています。私はPlistの名前を得ることができません。私は情報を抽出するために必要なプログラミングコードではあまり確かではないと思う。Xcodeを使用して辞書の配列を持つ私のPlistを読み書きします
あなたが良いチュートリアルやサンプルコードを提供することによって助けになるなら、素晴らしいだろう。ありがとう!
<array>
<dict>
<key>Name</key>
<string>Device 2</string>
</dict>
<dict>
<key>Name</key>
<string>Device 1</string>
</dict>
</array>
これらのコードは私のtableViewで
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:@"devicelist" ofType:@"plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:path]) {
NSLog(@"The file exists");
} else {
NSLog(@"The file does not exist");
}
contentDict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
NSLog(@"The count: %i", [contentDict count]);
contentArray = [NSMutableArray arrayWithContentsOfFile:path];
NSLog(@"The array: %i", [contentArray count]);
[contentArray retain];
[contentDict retain];
[mainTableView reloadData];
及びこれらの..私のviewDidLoadで..です
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier]autorelease];
}
cell.textLabel.text = [sortedArray objectForKey:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
ありがとう! :) – AlwynIsPat