如何构建类i iphone应用程序 [英] how to structure classes i an iphone application

查看:89
本文介绍了如何构建类i iphone应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个应用程序,用户必须输入一个苍蝇编号并单击确定。我得到了这个飞行并联系RESTful网络服务( http://www.webserviceadress.com:8080/ getStatut /用户放置的苍蝇编号)获取JSON结果解析它并将结果放入表View。

I want to make an application, user have to put a fly number and click ok. I get this fly and contact a RESTful web service ( http://www.webserviceadress.com:8080/getStatut/The fly number that user put) get the JSON result parse it and put the result in a table View.

我应该使用哪些类使?我应该使用委托吗?

What are the classes that I should make? Should I use delegate?

我正在考虑创建一个带有.xib的类Stauts和属性flyNumber .a类,其中包含表视图的xib和方法将结果放在表格视图中。还有一个将联系Web服务并解析JSON的类。此类应该委派类状态。

I am thinking to create a class Stauts with the .xib and the attribute flyNumber .a class with the xib of the table view and the method who will put the result in the table view . And a class who will contact the webservice and parse JSON. And this class should delegate the class status.

是否正确?

推荐答案

您的问题有一百万个答案,但作为示例,您可以尝试将网络代码架构为任务或操作。例如,如果您对服务的操作是用于提交数字,则可以创建 SubmitNumberOperation SubmitNumberTask 或许接受一个关键/值对的NSDictionary,它将是给予服务的参数。调用网络调用,然后您可以让处理程序调用一些接收服务器的json响应的 parseResult 方法。我们的想法是拥有一个基类 NetworkOperation ,它可以为您启动所有网络请求,方法是调用 parseResult 。这将允许您覆盖子类中的parseResult。

You question has a million answers, but as an example you can try to architect your network code into tasks or operations. For example, if you had an operation on service that was for submitting numbers, you can create a SubmitNumberOperation or SubmitNumberTask that perhaps takes in an NSDictionary of key/value pairs that will be the parameters given to the service. Invoke the network call and then you can have the handler call some parseResult method that takes in the server's json response. The idea would be to have a base class NetworkOperation that does all the network request launching for you that way you can have it call parseResult. This would allow you to override parseResult in your subclasses.

这篇关于如何构建类i iphone应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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