Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

milktooth

macrumors member
Original poster
Oct 30, 2009
32
0
No. People do.



I only have an iPod touch and don't have access to an iPhone. I'm writing a countdown timer app but have concerns that incoming calls would interrupt its function.

What happens when phone calls are received or made? Are apps left running in the background?

Would an [NSTimer scheduledTimerWithTimeInterval...] be interrupted?
 

milktooth

macrumors member
Original poster
Oct 30, 2009
32
0
From Apple:

Even if your application is not designed to use iPhone-specific features like the camera, GPS, or Compass, when it runs on an iPhone it can encounter a number of unique situations. For instance, if a user accepts an incoming phone call while using your application, your application will quit. It must be prepared to handle this behavior. The right thing is to restore the user's state when they relaunch the application.
 

xsmasher

macrumors regular
Jul 18, 2008
140
0
I only have an iPod touch and don't have access to an iPhone. I'm writing a countdown timer app but have concerns that incoming calls would interrupt its function.

What happens when phone calls are received or made? Are apps left running in the background?

You can use the timer in the "clock" app to simulate an interruption. If the user gets a call you get applicationWillResignActive, if they decline the call you get applicationDidBecomeActive, and if they take the call your app gets terminated.

To simulate this, set a clock alarm for one minute and start your app. When the alarm window appears, you can click "ok" to simulate ignoring the call, or click the home button to simulate taking the call.
 

mkrishnan

Moderator emeritus
Jan 9, 2004
29,776
15
Grand Rapids, MI, USA
Sorry for butting in, I'm not a programmer, but I wondered... how is it that there were some programs in the past that could stay in a locked/paused state when a call came in? Gameloft's Ferrari GT -- this is an older game now -- could definitely do this.
 

xsmasher

macrumors regular
Jul 18, 2008
140
0
Sorry for butting in, I'm not a programmer, but I wondered... how is it that there were some programs in the past that could stay in a locked/paused state when a call came in? Gameloft's Ferrari GT -- this is an older game now -- could definitely do this.

You "fake it" by pausing the game when you lose focus, and saving the game when you get the termination message. When the game is started again, you look for a saved game file and load it if it exists. That's What I do in "Dead Panic."
 

mkrishnan

Moderator emeritus
Jan 9, 2004
29,776
15
Grand Rapids, MI, USA
You "fake it" by pausing the game when you lose focus, and saving the game when you get the termination message. When the game is started again, you look for a saved game file and load it if it exists. That's What I do in "Dead Panic."

That's possible, but it doesn't seem to be what that old app did -- now granted, this was some time and a number of OS revisions ago. It came back pretty instantly in paused mode (as opposed to any loading delay). I'd be curious to load it back on my iPhone and see if it still does this.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.