update tableview if data is changed online

我与影子孤独终老i 提交于 2019-12-30 11:07:55

问题


We are making an app for the hotel where we have already made an app where orders can be placed through app. All those orders can be seen on web portal by refreshing the page.

Now client requested to create an app where waiter can see the order on his iPad.

For that we will be having the tableview where all list of orders will be shown.

However I am not getting how I will refresh the table/ add the data if new order is made.

In short once order is made, at same instance waiter should get alert and table view should be updated.

Note: iPad/ iPhone get the data through webservice.


This can be achieved by calling webservice every 1 min or 30 seconds.

However I don't want to do this way...

If new stuff is added, webservice will send that data and I will add that data in my tableview. Means webservice will send me listener that new data is added

I need to know how can I listen this listener if webservice send me listener.

Any useful info on this would be appreciated.

Below link helped me for TCP in iOS.

http://www.tekritisoftware.com/sites/default/files/Socket_Programing_for_IOS.pdf


回答1:


You could implement it using a TCP-based client-server approach, where the iPad is the client.

  1. The iPad client connects to the server using authentication so you know which waiter is using the iPad.
  2. The TCP uses duplex communication over the TCP socket so either side can send a message to the other.
  3. If the server has something to give to the iPad/client/waiter then it simply sends it to them.
  4. If the client wants to send a message to the server, like "I'm taking a break", or whatever, then it simply sends it to the server.
  5. The range of information you can share between the client and server is actually unlimited.
  6. There is no 6.

This requires the server to be written as well, however, so this solution is more than just iOS development. However a webservice would need similar development anyway.



来源:https://stackoverflow.com/questions/21657022/update-tableview-if-data-is-changed-online

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!