RESTful iPhone客户端和模型层次结构 [英] RESTful iPhone client and Model hierarchy

查看:159
本文介绍了RESTful iPhone客户端和模型层次结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇你的大多数人采用什么策略,以便在模型层次结构中构建可靠的RESTful iPhone客户端。我的意思是模型层次结构是我有一个REST服务器,其中几个资源相互关联。例如,让我们说假设的目的我有一个REST服务器,它吐出关于学校的信息。如果我想抓住特定类中的所有学生,我首先需要向REST服务器查询学校的信息,然后我需要向服务器查询学校提供的所有类的信息,其次是随后请求特定课程中的所有学生。在一天结束时,客户端正在引入3个唯一的XML树。在这一点上,你们中的大多数人编写自己的算法,以构建最终的树,最终将成为你的数据源?你不是在这方面聚合XML树,而是使用不同的方法吗?

I'm curious what strategy most of you are employing in order to build solid RESTful iPhone clients in respect to model hierarchies. What I mean by model hierarchies is that I have a REST server in which several resources have a correlation to each other. For instance, let's say for hypothetical purposes I have a REST server which spits out information about a school. If I want to grab all the students in a particular class, I first need to query the REST server for information on the school, then I need to query the server for information on all of the classes the school has to offer, followed by a subsequent request for all students in a particular class. At the end of the day, the client is bringing in 3 unique XML trees. At that point, do most of you folks write your own algorithms in order to build the final tree which will end up being your data source? Do you not aggregate XML trees in this respect and instead use a different approach?

你喜欢在服务器上使用大量的相关资源,

How do you prefer taking a myriad of related resources on the server and getting them into one tree that just makes sense onto the client?

推荐答案

如何选择存储在iPhone上管理模型数据可能取决于您处理的XML数据的多少可能会有所不同,以及它可能获得多大的膨胀。

How you choose to store manage your model data on the iPhone probably depends on how much the XML data you are dealing with is likely to vary, and how bloated it might get.

如果这是一个不太可能改变的简单XML模型,并且它不包含非常多的冗余信息,那么可以使用XML树你就是这样描述的。

If this is a simple XML model that is unlikely to change, and doesn't carry terribly much redundant information with it, you might do well to just use the XML trees you describe as-is.

但是对于任何更复杂的事情,我更喜欢将XML表示形式转换为我的Objective-C代码最容易操作的格式。例如,考虑您的应用程序扩展一天的可能性,以支持提供类似数据,但作为JSON或SOAP格式的数据的其他基于Web的服务。现在你开始陷入在你的应用程序中维护3种不同类型的模型的头痛,当时最好只保留一个。

But for anything even slightly more complex, I prefer to translate XML representations into a format that is most easily manipulated by my Objective-C code. Consider for example the possibility that your application expands one day to support other web-based services that provide similar data, but as JSON or SOAP formatted data. Now you start to run into the headaches of maintaining 3 different types of models in your application, when it would be preferable to maintain just one.

我会把XML-基于REST的REST资源作为外部数据,需要按照本地可操作的格式。如果您采用最大限度地提高应用特定操作的便利性的本地格式,则可以调整任何其他外部格式的输入,并根据需要将其转换回上传/编辑/任何格式的外部格式。

I would treat the XML-based REST resources as "foreign data" that need to be massaged into a locally manipulatable format. If you adopt a local format that maximizes the ease of performing your app-specific operations, then you can adapt inputs from any other foreign format, and convert back to foreign formats as needed for uploads/edits/whatever.

丹尼尔

这篇关于RESTful iPhone客户端和模型层次结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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