0

My basic requirement is to poll the server every 5 seconds and fetch some data. This activity should not freeze/affect the UI in anyway. The data would make minor updates to the UI.

The calls made to the server are made using AFNetworking. I would have preferred NSThread over NSTimer but I am confused that do I really need a separate thread since AFNetworking makes async calls the backend?

I don't want the overall performance of the application(IPOD/IPAD application) to take a hit. Which way should be preferred?

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
Peyush Goel
  • 383
  • 2
  • 3
  • 13
  • The answer to this question is try it and see which one works better. – borrrden Oct 30 '12 at 12:26
  • in my local environment, it won't show any issues. but in the production environment, there might be performance issues which I don't want... so hit and trial won't help much – Peyush Goel Oct 31 '12 at 09:42
  • 1
    The preferred way would be not polling the server at that rate: if you need frequent updates, consider switching from discrete requests to a streaming connection. Especially over cellular, one request per 5 seconds is ludacrous. If you need a cross-platform solution, consider using Socket IO. If the backend is out of your control, consider building a proxying service to poll the origin and push changes to the connected clients through a streaming connection. – danyowdee Nov 03 '12 at 11:09
  • basically the idea is to use sockets, but in case the connection fails, use the default way to fetch data. currently socket isn't implemented on the server side. When you say - "building a proxying service to poll the origin and push changes to the connected clients through a streaming connection." - i am looking for the best way to do that. it would kind of poll and ask for data every 5 seconds from the server. in case action is required, update ui. otherwise ignore – Peyush Goel Nov 05 '12 at 13:32

0 Answers0