Terminate the app without user interaction

Discussion in 'iOS Programming' started by RossOliver, Aug 18, 2008.

  1. RossOliver macrumors regular

    Joined:
    Nov 6, 2006
    #1
    Hey,

    Is there a way to kill the application (so the applicationWillTerminate is called) without the user pressing their home button?

    Thanks,

    -Ross
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    See my thread here. I'm pretty sure the delegate methods get called...
     
  3. RossOliver thread starter macrumors regular

    Joined:
    Nov 6, 2006
    #3
    The delegate methods do get called, but I'm not so keen on the compiler warning... I may try a different approach that just blocks the user by way of disabling interface components so all they can do is hit the home button...

    Cheers,

    -Ross
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Use this to remove the compiler warning:

    Code:
    	[[UIApplication sharedApplication] performSelector:@selector(terminateWithSuccess)];
    
    Of course if Apple change this private API this will stop working.
     
  5. RossOliver thread starter macrumors regular

    Joined:
    Nov 6, 2006
    #5
    Thanks for the tip - but as you say, apple may update the API and wreck this workaround... I think it will be best if I find a more standard way...
     
  6. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #6
    I looked into this for a while a few days ago. AFAIK, terminate and terminateWithSuccess (both private methods BTW) don't do the spiffy animation when you quit. They just close your app immediately. I think that animation is a system animation and can't be used by your app. I hacked around the simulator files with class-dump and nm but didn't find anything.

    One alternative I tried was displaying an alert view repeatedly telling the user to quit the app. But I settled on just transitioning the app to a different view (my app has a startup view) that the user can't use the app from.

    So I would rethink what exactly you're trying to do.
     

Share This Page