-5

I'm using Objective-C for iPhone development and I'm wondering how to create a method that checks something (maybe make a GET request to some API every hour) even when the app closed.

Is there any built-in mechanism that can do that?

Nir Gofman
  • 164
  • 1
  • 11
  • 3
    You should explain what you're trying to accomplish, because while using a timer will work, it might not be the best way to solve your problem. – rdelmar Dec 14 '14 at 18:13
  • refer this http://stackoverflow.com/questions/19608044/how-to-stop-nstimer-at-a-specific-point/19609863#19609863 – Hussain Shabbir Dec 14 '14 at 18:30
  • As @rdelmar stated, you should be specific with what you want- there are ways to achieve this but not all ways can solve your specific requirement. – z22 Dec 15 '14 at 05:58

1 Answers1

1

"Run always?" What does that mean? If you have a "while (true) block in your program it will lock up and the system will kill it for being frozen.

iOS devices are event driven, and need processor time to respond to user actions and system events.

Probably your best bet is a repeating timer on a fairly short interval. I would advise against making the interval much shorter than 50 times a second though, since timers aren't accurate at intervals shorter than that.

What is the problem you're trying to solve?

Duncan C
  • 128,072
  • 22
  • 173
  • 272