iPhone。与 HTTP 服务器建立二进制数据流
如何为 iPhone 通过 HTTP 建立输入流?我的项目是将二进制数据从 HTTP 服务器逐步拉取到 iPhone。该模式是提取一些数据 - 这是一个科学应用程序 - 分析一段时间,提取更多数据。冲洗,然后重复。
该项目是桌面 Java 应用程序的一个端口,它依赖于 InputStream 及其方法 readInt、readString 等来执行此操作。
干杯, 道格
How do I establish an input stream over HTTP for the iPhone? My project is to incrementally pull binary data from an HTTP server to the iPhone. The pattern is to pull some data - this is a scientific app - analyze it for a while, pull more data. Rince, and repeat.
This project is a port of a desktop Java app which relies on InputStream and it's methods readInt, readString, etc. to do this.
Cheers,
Doug
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 NSURLRequest/NSURLMutableRequest 与 NSURLConnection 一起使用,以实现此目的,这里有一些链接 http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/Reference/Reference.html, http://developer.apple. com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html
You can use NSURLRequest/NSURLMutableRequest along with NSURLConnection in order to achieve this here are some links http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/Reference/Reference.html, http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html
如果您想要一个更直接地反映 Java 输入流的 API,您可能需要看看基于 C 的 CFNetwork。然而,Daniel 建议使用 URL 加载系统(NSURLRequest、NSURLConnection 等)是更好的选择,因为它使用 Objective-C 并且在异步模式下非常易于使用。与简单的 java.io 相比,它更多地打破了旧的 stdio.h 函数,并且非常值得您花时间来理解它。
If you want an API that more directly mirrors the Java input stream, you may want to look at the C-based CFNetwork. However, Daniel's suggestion to use the URL Loading System (NSURLRequest, NSURLConnection, etc.) is preferable because it uses Objective-C and is really easy to use in asynchronous mode. It makes more of a break from the old stdio.h functions than the simplistic java.io does, and it's well worth your time to understand it.