1

I have an iPhone application in which I would like to give the user the option of turning a setting on/off depending on wether or not they would like the application to exit when suspended (or going into the background).

As I understand it, there is an option in the info.plist file called something like "UIApplicationExitsOnSuspend" which can be turned on to allow this functionality, I also understand the info.plist file shouldn't (can't?) be modified at run-time.

Though not a massively important feature, I would like to find a way to implement something if possible, can anyone shed some light on this?

Jack

Jack Nutkins
  • 1,555
  • 5
  • 36
  • 71

2 Answers2

2

You should not to that.

First of the UIApplicationExitsOnSuspend is a settings in the apps info.plist which is read only thus can not be changed.

Also there is not need to exit your app, just let it be pushed to the background. If the systeem need more memory it will kill your to free the memory it is using.

rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • Yes, all settings in the `info.plist` are read only since this file is in the main bundle which is readonly. – rckoenes Nov 14 '16 at 08:37
0

You're right on the read-only state of the plist at runtime.

You could try something like

-(void)applicationDidEnterBackground:(UIApplication *)application {
      if (...) {
            exit(0);
      }
}

But apple is not happy (= rejects apps) that do not comply to their App Submission Guidelines and 10.1 in particular:

10.1: Apps must comply with all terms and conditions explained in the Apple iPhone Human Interface Guidelines and the Apple iPad Human Interface Guidelines

basvk
  • 4,437
  • 3
  • 29
  • 49
  • Last I checked, -applicationDidEnterBackground: is called during display sleep; not only when the app is "backgrounded". (I was trying to distinguish between someone switching to the app and un-sleeping the phone and found it was not possible to do reliably.) – tc. Jun 11 '12 at 15:46