-1

I have a tableview that displays RSS feeds and I have successfully managed to integrate a pull to refresh control to gather the latest feeds.

However if there is no internet connection the tableview just refreshes infinitely and the

[self.refreshControl endRefreshing];

method is never called, leaving the tableview in a locked state of refreshing.

My question is how can I call the endRefreshing method if after a certain period of time the tableview is still refreshing?

e.g. after 10 seconds, if the tableview is still refreshing, the endRefreshing method is called.

thanks!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Jay Chauhan
  • 99
  • 1
  • 9
  • I dont understand your problem. You wrote the code for the tableviews datasource. So it is up to you to give no data back if the internet connection is lost, so that the table stops refreshing. – Thallius Jan 25 '15 at 13:07
  • I'd be careful with using that approach as @ClausBönnhoff said i'd much rather bind the refreshing of the UI to the current state of the data source. – MrBr Jan 25 '15 at 13:09
  • So if it's still refreshing after a long time, trick the data refresh method in to thinking there is no new data so it ends the refresh? – Jay Chauhan Jan 25 '15 at 13:36
  • Did you wrote the code by yourself or did you copy and paste it from an tutorial? You normally write the datasource by yourself. the datasource fills the tableview with data. There are mathods called cellForRowAtIndexPath() and other ones which are used for that. So you have the control of what is happening when the tableview refreshes and so its up to you to tell the tableview that there is no new data when there is no internet connection. That has nothing to do with a trick. – Thallius Jan 25 '15 at 13:43
  • I followed a tutorial which explained how you would go about creating an RSS feed reader – Jay Chauhan Jan 27 '15 at 00:15

1 Answers1

0

Use NSTimer

[NSTimer scheduledTimerWithTimeInterval:2.0
    target:self
    selector:@selector(targetMethod:)
    userInfo:nil
    repeats:NO];
Priyatham51
  • 1,864
  • 1
  • 16
  • 24