iOS / Restkit应用程序设计 [英] iOS/Restkit application design

查看:105
本文介绍了iOS / Restkit应用程序设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个由rails支持的iOS应用程序。对于iOS和rails之间的通信,我使用RESTkit框架,因为它占用了大量的工作!

I'm currently developing an application for iOS that is backed by rails. For the communication between iOS and rails i use RESTkit framework since it takes away a lot of work!

我对如何在代码开始增长时管理代码有些怀疑!使用RESTKit时如何设计应用程序?您为控制器提供了哪种数据层来执行不同的操作?

I have some doubts on how to manage the code when it starts to grow! How do you design your applications when you use RESTKit? What kind of data layer do you provide to your controllers to perform different actions?

谢谢

推荐答案

我通常更喜欢创建单例数据控制器它提供了模型对象和正在执行的人类可理解操作的API(getPost,addCommentToPost,createPost,...)。这给了控制器获取数据的一个地方,这意味着我不需要传递数据控制器。它还意味着所有映射都在一个地方并与其余代码隔离(因此当服务器更改时,我不需要更改控制器中的任何代码,只需映射到模型对象的代码) 。

I usually prefer to create a singleton data controller which provides an API in terms of the model objects and the human understandable operation being performed (getPost, addCommentToPost, createPost, ...). This gives one place that controllers go to get data and means I don't need to pass the data controller around. It also means that all of the mappings are in one place and are isolated from the rest of the code (so when the server changes I don't need to change any code in the controllers, just the code which maps into the model objects).

这篇关于iOS / Restkit应用程序设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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