开发者

iPhone live data streaming

开发者 https://www.devze.com 2023-03-12 10:22 出处:网络
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

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?


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 :)


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

-(void)reloadData; -(void)reloadDataIfNeeded;

Check NSURLConnection for asynchronous loads of a URL request. NSOperation for start you code in background.

0

精彩评论

暂无评论...
验证码 换一张
取 消