如何使用 Web 请求结果(xml、plist 等)作为 UITableView 的数据源
我想使用 Coldfusion Web 查询结果来填充 iOS 中的 UITableView。查询结果以字符串形式返回,我想我需要将它们转换为 NSArray 或 NSDictionary...
谢谢,Phill
I want to use coldfusion web query results to populate a UITableView in iOS. The query results come back as a string and I guess I need to convert them to NSArray or NSDictionary...
Thanks, Phill
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您所需要做的就是实现
UITableViewDataSource
协议,并将实现挂接到表视图的dataSource
出口。这样你就得到了冷融合结果,然后告诉表视图重新加载。查看协议的文档以了解您需要实现哪些方法。All you need to is implement the
UITableViewDataSource
protocol, and hook the implementation up to the table view'sdataSource
outlet. So you get your coldfusion results, then tell the table view to reload. Look at the documentation for the protocol to see which methods you need to implement.嗯,这取决于返回结果的格式。如果它是 XML,您将需要解析 XML,将结果保存在某种数据对象中。然后使用 UITableViewController 的 cellForRowAtIndexPath 方法来访问正确的结果并显示它。
查看 SeismicXML 示例代码。我认为这将帮助您实现您想要的目标:
https://developer.apple.com/library/ios/#samplecode/SeismicXML/Introduction/Intro.html
Well, it depends on what format the results come back as. If it's XML, you'll want to parse the XML, keep the results in some sort of data object. Then use your UITableViewController's cellForRowAtIndexPath method to access the right result and display it.
Take a look at the SeismicXML sample code. I think it will go a long way to getting you where you want to go on this:
https://developer.apple.com/library/ios/#samplecode/SeismicXML/Introduction/Intro.html