简体   繁体   English

如何在 iPhone 应用程序中显示实时数据?

[英]How to display live data in iphone app?

I am building an iphone app for my local high school football team.我正在为我当地的高中橄榄球队构建一个 iphone 应用程序。 What is the best way to show live data for the scores of games without using a sql db and having to updated the entire app after every game.在不使用 sql db 并且必须在每场比赛后更新整个应用程序的情况下,显示比赛得分实时数据的最佳方式是什么?

there are a few ways of doing it, one would be to create an rss feed on a remote server, and parse that, and if you wanted realtime updates, you could use push notifications.有几种方法可以做到这一点,一种是在远程服务器上创建一个 rss 提要,然后解析它,如果你想要实时更新,你可以使用推送通知。

If you plan on creating the app to only show what the end result of each game was you can use NSXMLParser as @MCannon suggests.如果您计划创建应用程序以仅显示每个游戏的最终结果,您可以按照@MCannon 的建议使用 NSXMLParser。 If you plan on having the app update in REAL TIME, as in. "The ball is on the 45 Yard line, 3rd and 3".如果您计划实时更新应用程序,例如“球在 45 码线上,3 号和 3 号”。 Then you can stick with NSXMLParser but create a NSTimer to update the information every 30 seconds or so.然后您可以坚持使用 NSXMLParser,但创建一个 NSTimer 以每 30 秒左右更新一次信息。

That would also mean you would need to have the RSS feed updated in real time as well.这也意味着您还需要实时更新 RSS 提要。

The only way to do what you're asking is to have the data stored on the internet in some fashion, then build into your app a routine for consulting the remote data source (on the internet) and update its internal storage accordingly.完成您要求的唯一方法是以某种方式将数据存储在 Internet 上,然后在您的应用程序中构建一个例程,用于查询远程数据源(在 Internet 上)并相应地更新其内部存储。

It can be done with no DB but the data must exist and be accessible over the internet.它可以在没有数据库的情况下完成,但数据必须存在并且可以通过互联网访问。 As others have suggested, an RSS feed would be a great way to pipe in the data.正如其他人所建议的那样,RSS 提要是数据中 pipe 的好方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM