所以这是我的代码。我正在尝试将 plist 中的内容显示到表格中,但我一直遇到错误。我整天都在做,所以我可能错过了一些相当容易的东西。希望你们能弄清楚为什么当我建造时,桌子是空的。
这是我的 plist(没有标题):
<array>
<dict>
<key>word</key>
<string>AWord1</string>
<key>definition</key>
<string>here is a definition</string>
<key>partOfSpeech</key>
<string>here is a part of speech</string>
</dict>
<dict>
<key>word</key>
<string>Bword1</string>
<key>definition</key>
<string>here is a definition</string>
<key>partOfSpeech</key>
<string>here is a part of speech</string>
</dict>
</array>
</plist>
编辑:由于格式错误而缺少结束标签 - 已修复
好的。这是我的新代码。我 NSLog'd 并决定在我去 plist 之前备份。所以,如果你能帮忙的话。你会如何建议我从 plist 中提取这些数据(假设数据在 plist 中)
//Initialize the array.
listOfItems = [[NSMutableArray alloc] init];
NSArray *countriesToLiveInArray = [NSArray arrayWithObjects:@"Iceland", @"Greenland", @"Switzerland", @"Norway", @"New Zealand", @"Greece", @"Italy", @"Ireland", nil];
NSDictionary *countriesToLiveInDict = [NSDictionary dictionaryWithObject:countriesToLiveInArray forKey:@"Countries"];
NSArray *countriesLivedInArray = [NSArray arrayWithObjects:@"India", @"U.S.A", @"Test", @"Test", @"Test", @"Test", @"Test", @"Test", @"Test", @"Test", @"Test", @"Test", @"Test", @"Test", @"Test", @"Test", nil];
NSDictionary *countriesLivedInDict = [NSDictionary dictionaryWithObject:countriesLivedInArray forKey:@"Countries"];
[listOfItems addObject:countriesToLiveInDict];
[listOfItems addObject:countriesLivedInDict];
//Initialize the copy array.
copyListOfItems = [[NSMutableArray alloc] init];
//Set the title
self.navigationItem.title = @"Countries";
//Add the search bar
self.tableView.tableHeaderView = searchBar;
searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
searching = NO;
letUserSelectRow = YES;
我觉得好像我仍然没有真正告诉它解析来自 plist 的数据。我只是初始化它。想法?