从 UITableView 中的 PList 获取单元格标题的问题
只是在读取 PList 并在 tableView 控制器中设置 cell.textLabel.text 时遇到一个非常愚蠢的问题。
我的 PList 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Rows</key>
<array>
<dict>
<key>Name</key>
<string>Big Ben</string>
</dict>
<dict>
<key>Name</key>
<string>Westminster Abbey</string>
</dict>
</array>
<key>Title</key>
<string>London</string>
</dict>
<dict>
<key>Rows</key>
<array>
<dict>
<key>Name</key>
<string>Eiffel Tower</string>
</dict>
</array>
<key>Title</key>
<string>Paris</string>
</dict>
</array>
</plist>
我只是想将名称放入单元格中。这就是我到目前为止所拥有的。
cell.textLabel.text = [[[[[tableData objectAtIndex: indexPath.section] objectForKey: @"Rows"] objectAtIndex: indexPath.section] objectForKey: @"Name"] objectAtIndex: indexPath.row];
提前致谢。
just having a really silly problem with reading the PList and setting the cell.textLabel.text in a tableView controller.
My PList looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Rows</key>
<array>
<dict>
<key>Name</key>
<string>Big Ben</string>
</dict>
<dict>
<key>Name</key>
<string>Westminster Abbey</string>
</dict>
</array>
<key>Title</key>
<string>London</string>
</dict>
<dict>
<key>Rows</key>
<array>
<dict>
<key>Name</key>
<string>Eiffel Tower</string>
</dict>
</array>
<key>Title</key>
<string>Paris</string>
</dict>
</array>
</plist>
And I am just trying to get the name into the cell. This is what I have sofar.
cell.textLabel.text = [[[[[tableData objectAtIndex: indexPath.section] objectForKey: @"Rows"] objectAtIndex: indexPath.section] objectForKey: @"Name"] objectAtIndex: indexPath.row];
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
感谢@aBitObious 的建议 - 已排序。答案是:
Thanks to @aBitObious for your advice - got is sorted. Answer is:
试试这个:
.m
.h
我的 plist 名为 lodges.plist 只需根据需要更改信息即可工作。我还为您添加了字幕。
Try this:
.m
.h
my plist is named lodges.plist just change the information as needed and it will work. I have also added subtitles for you as well.