远程 xml 文件和 uinavigationcontroller、nsurlconnection 放置
首先,我研究了苹果的示例代码:SeismicXML 和 TopSongs,但是它们和其他教程通常在应用程序委托中调用 NSURLConnection
。
在我丑陋的项目中,在用户到达 uinavigationcontroller 中的某个视图控制器后,我必须调用 NSURLConnection
。
所以,我问这个设计问题,我是否应该在应用程序委托中保留 NSURLConnection
方法,并从我的互联网感知 vc 进行调用,或者完全将此 NSURLConnection
方法和委托移至我的互联网意识VC?
另外,还有另一个设计问题让我很困惑,因为我什至不是初学者:)
我必须保留从 xml 构造的视图 uitableview 的数量,及其 详细视图。因此,我认为我必须向我的网络服务发出两个请求。一是获取 xml 文件,二是必须进行详细视图以增加 Web 服务中相关数据的查看次数。
但是,我认为这不是一个好的解决方案,是否有任何库或任何其他方法来保留此列表及其详细视图计数并通知我的服务器?
Firstly, I studied apple's sample codes : SeismicXML and TopSongs but both of them and other tutorials generally calls NSURLConnection
in app delegate.
In my ugly project, I have to call NSURLConnection
after user reach some viewcontroller in uinavigationcontroller.
So, I'm asking this design issue, Should I still keep NSURLConnection
methods in app delegate, and calling from my internet aware vc or completely move this NSURLConnection
methods and delegates to my internet aware vc ?
Also, there is another design issues which mess my head since I'm not even starter :)
I have to keep the number of view uitableview which is constructed from xml, and its
detailed view. Therefore, I think that I must two request to my web service. One to getting xml file and the other one must be made in detailed view to increase view count of related data in web service.
But, I think that it's not a good solution, Is there any library or any other approach to keep this list and its detailed view counts and notify my server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的方法是创建一个单独的类,仅用于连接调用和方法,从委托中实例化它,从委托中将该实例设置为属性(或手动创建其 setter 和 getter)并在任何类中使用/控制器我想要。
通过这种方式,您可以模块化应用程序,并且类不会混乱,并且更容易调试/遵循应用程序的流程。
The way I do it is make a separate class that I use only for connection calls and methods, instantiate it from the delegate, set that instance from the delegate as a property (or manually create its setters and getters) and use in in any class/controller I want to.
This way you modularize your application and the classes don't get tangled up and it's easier to debug/follow the flow of the application.