iPhone 实时数据流
我们有一个带有图表的应用程序。客户想要实现类似外汇图表的功能,我指的是实时数据,例如每 1、5 或 10 秒更新一次。您能给我提供一些理论吗?如何实现?我应该使用哪些 iOs 对象?数据提供者应该实施什么?
We have an application with charts. Client wants to implement something like in forex graphs, I mean live data, updating for example each 1, 5 or 10 seconds. Could you please provide me with some theory, how would it be possible to implement, what iOs objects should I use? What should the data provider implement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您正在使用 API 来接收应用程序的实时数据。 API 最好使用 JSON 格式发送数据。因为那些很容易使用。如果以 XML 格式接收数据则有点困难。网上有JSON类库可以下载。下载它并将其集成到您的应用程序中,然后您就可以非常轻松地使用它。
http://mobileorchard.com/tutorial-json-over-http- on-the-iphone/
这是一个教程。你可以参考一下,很简单:)
I think you are using API s to receive live data to your application. its better that APIs are using JSON format to send data. because those are easy to use. If the data receiving in XML format then its little bit hard. There is JSON class library in the internet to download. Download it and integrate it your application and after that you can use it very easily.
http://mobileorchard.com/tutorial-json-over-http-on-the-iphone/
here is a tutorial. you can refer it and its easy :)
图表数据应位于任何服务器端。创建单独的线程,向您/客户端服务器端发送请求或异步请求。这将使您的请求在后台运行,并且应用程序的用户不会因应用程序生命周期中无休止的停止/暂停而分心。同样在后台,您应该解析从服务器接收到的数据。有多种可用格式可用于此目的(例如上一篇文章中的 JSON)。解析数据并更新您的图表数据源。如果您使用 CorePlot 构建图表,则使用新数据刷新图表非常简单 - 使用这些 CPGraph 方法
检查 NSURLConnection 用于异步加载 URL 请求。 NSOperation 用于开始编写代码背景。
Data for charts should locates on any server side. Create separate thread with requests or async requests to your/clients server side. This will make your requests in the background and users of your application will not be distracted by endless stop/pause during the application lifecycle. Also in the background you should parse received data from server. There are multiple available formats for this aim (JSON in prev post, for ex.). Parse data and update your charts datasource. If your use CorePlot for building charts it's pretty straightforward to refresh charts with new data - use on these CPGraph methods
Check NSURLConnection for asynchronous loads of a URL request. NSOperation for start you code in background.