вот моя проблема, я пытаюсь создать UITableView, который может отображать имена из моего списка в ячейках. Я не могу получить имена из Плиста. думаю, я не совсем уверен в том, какие программные коды необходимы для извлечения информации.
Если бы вы могли помочь, предоставив хороший учебник или примеры кодов, было бы замечательно. Спасибо!
<array>
<dict>
<key>Name</key>
<string>Device 2</string>
</dict>
<dict>
<key>Name</key>
<string>Device 1</string>
</dict>
</array>
Эти коды на мой взгляд DidLoad ..
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];
и это в моем tableView ..
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;