问题
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.
- The iPad client connects to the server using authentication so you know which waiter is using the iPad.
- The TCP uses duplex communication over the TCP socket so either side can send a message to the other.
- If the server has something to give to the iPad/client/waiter then it simply sends it to them.
- 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.
- The range of information you can share between the client and server is actually unlimited.
- 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