Objective-C(Desktop)XML文件/网页到NSTableView [英] Objective-C (Desktop) XML file/web page to NSTableView

查看:141
本文介绍了Objective-C(Desktop)XML文件/网页到NSTableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从私人API检索XML文档,然后将其解析为表视图。



我浏览了几篇文章,但我找不到任何帮助我的东西。



有没有人有任何文章,教程,示例等可以帮助我?



提前感谢!

解决方案

我认为这可以分为两个问题: / p>

第一个:解析XML



有两种方法可以做到: event-驱动XML ;我强烈喜欢基于树的XML 。你应该阅读一下这些教程,看看哪一个是最有意义的;



第二:使用表格视图 b

将XML解析为某种字典或自定义对象后,您需要在表视图中显示该对象的信息。为此,我建议绑定。 这篇CocoaDevCentral教程介绍如何使用绑定在nstableview。 (它甚至覆盖使用多个表视图创建一个Mail.app类似的界面,你可能会或可能不是有用的。)



或...替代方法,灵活性较低的方法



基于树状的XML ,将NSXMLDocument对象直接绑定到表视图。如果你确定你将以这种直接的方式修改XML(例如,如果你正在写一个XML编辑器!),那么也许这是一个好主意,你应该查看此样本项目



祝你好运!


I'm looking to retrieve an XML document from a private API, then parse it into a table view.

I've looked through a few articles but I can't find anything that has helped me fully.

Does anyone have any articles, tutorials, examples, etc that can help me out?

Thanks in advance!

解决方案

I'd say this can be split into two problems:

First: Parsing XML

There are two ways to do this: some like event-driven XML; I strongly prefer tree-based XML. You should read a little into each of those tutorials and see which makes the most sense to you; I bet you'll prefer one of them based on your past programming experiences.

Second: Using Table Views

Once you've parsed your XML into some sort of dictionary or custom object, you'll need to display that object's information in a table view. For that, I suggest bindings. This CocoaDevCentral tutorial explains how to use bindings to display information in an NSTableView. (It even covers using multiple table views to create a Mail.app-like interface, which you may or may not find useful.)

Or... An Alternative, Less Flexible Method

In the guide for tree-based XML, there's a section on binding NSXMLDocument objects directly to table views. If you're sure that you'll be modifying the XML in such a direct way (for example, if you were writing, say, an XML editor!), then maybe that's a good idea, and you should check out this sample project. Otherwise, it'll be inflexible and you'll have to change it soon as you add features.

Good luck!

这篇关于Objective-C(Desktop)XML文件/网页到NSTableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆