我试图从远程服务器上的plist显示关键字"word"中的所有单词。列表如下:
<plist version="1.0">
<array>
<dict>
<key>word</key>
<string>wordhere</string>
<key>definition</key>
<string>definition Here</string>
<key>partOfSpeech</key>
<string>part of speech here</string>
<key>crossReference</key>
<string>cross reference here</string>
</dict>
<dict>
<key>word</key>
<string>wordhere2</string>
<key>definition</key>
<string>definition here2</string>
<key>partOfSPeech</key>
<string>part of speech here2</string>
<key>crossReference</key>
<string>cross reference here2</string>
</dict>
Update可以忽略pllist。我重写了它,所以它是一个硬编码数组。还是同样的错误。我已经访问了plist的url,所以我知道这是可行的。这是我的代码。不知道什么原因,我跑步的时候它不能进入我的合适位置。也许我遗漏了什么。我只是想要关键字填充形成合适的列表。D updated
[super viewDidLoad];
self.title = @"Dictionary";
[myArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"word1", @"word", @"Definition1", @"definition", @"Part of speech1", @"partOfSpeech", @"cross Reference1", @"crossReference", nil]];
这里是UITableViewCell
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]
;
}
cell.textLabel.text = [[myArray objectAtIndex:indexPath.row] objectForKey:@"word"];
给定myArray
是一个字典数组,那么这个应该工作:
cell.textLabel.text = [[myArray objectAtIndex:indexPath.row] objectForKey:@"key"];