0

I know this question has been asked many times and we have gotten this link as an answer from Apple: http://developer.apple.com/library/ios/#qa/qa1561/

However, recently, I met with this case below. I don't see any other options except using 'exit(0)' directly.

I have an app which can collect digital data from camera or microphone of my iPhone. Then I designed a button which reads 'Save and Exit', because this is a very common scenario of my app.

Without the capability to exit my app programatically, I can only have a stupid 'Save' button. Then my users have to click twice ( 1. the 'Save' button, and then 2. the 'Home' button ) to get the same result - a.k.a these two actions in sequence together.

Then I realized, maybe, this is a flaw of my design. Hence I changed it this way.

I removed the 'Save the Exit' button and, instead, added a note in the bottom says 'Use HOME button to SAVE & EXIT'. I tried to catch the quitting signal from users' action and then do the SAVE in prior.

By doing this, user can simply use the native HOME button to do the 'SAVE and EXIT'.

However, this solution is not perfect.

If my app takes too long to save the data, there's still a chance for iOS to kill my app after user hits the 'HOME' button. Then user can lost their data without notice!

If I can exit programmatically, I can try to 'SAVE' first. If 'SAVE' fails, I have plenty of time to inform my user or do all the remediation work needed.

Do you think this is a valid justification to use 'exit(0)' in my app without being rejected?

Cœur
  • 37,241
  • 25
  • 195
  • 267
aXqd
  • 733
  • 5
  • 17
  • 1
    Why would a user need to exit in the first place? As you state, the home button on the device already let's them leave the current app. If the issue is that the app is in the process of doing something you either a) need to have a message show that says "DO NOT EXIT UNTIL DONE" or, more ideal b) make sure the app can do processing in the background – DA. Jul 01 '11 at 15:56
  • @DA 1. multitasking(background processing) is not available in some old devices; 2. after the photo shotting or audio recording, users need to exit, because they have done with this app for this time. Otherwise, according to the current design, the next round of photo-taking or audio recording starts automatically. Without this capability, they have to click twice to save and quit. – aXqd Jul 01 '11 at 16:10
  • @PengOne How exactly? :D Are you suggesting writing a letter to Jobs? – aXqd Jul 01 '11 at 16:11
  • @aXqd: Sure, or ask in an Apple forum. Or read Apple's guidelines. No one here can tell you for certain anyway. – PengOne Jul 01 '11 at 16:13
  • @PengOne You are right. I am just thinking if you guys agree this is a valid justification, I can then write a mail to Apple with the link of this page as a support. :P – aXqd Jul 01 '11 at 16:19
  • @aXqd: Good luck with that. Let me know if you want a personal letter of support to append ;-) – PengOne Jul 01 '11 at 16:51

2 Answers2

2

No, I very much doubt that Apple will let you have a "save and exit" button. It goes completely against the platform conventions and directly contradicts Apple's HIG.

Under which circumstances do you think you'll have data that can't be saved in the amount of time iOS gives an app to clean up? Have you actually measured this and found it to be a problem?

Jim
  • 72,985
  • 14
  • 101
  • 108
  • No, so far, I don't have any measurement to prove this. But the consequence is quite severe. I don't have a return value to indicate if it is successful or not because my app has been killed. Meanwhile I simply lost my data without any chance to notify my user. – aXqd Jul 01 '11 at 16:23
  • And also, the amount of data is up to user. But, yes, I think I can add some restrictions. – aXqd Jul 01 '11 at 16:26
  • The consequences aren't severe at all if it doesn't happen. Figure out if it's a problem before trying to redesign your app to break Apple's rules. You've got about five seconds to clean up after your app, you can save a significant amount of data in that time. How much data do you have that you think five seconds isn't enough? – Jim Jul 01 '11 at 16:31
  • Thanks. You are right about that I need some more statistics to worry about the performance. But how about the remediation work if bad things happen? If the big SAVE fails, I have the needs to ask user to make their decisions. I don't know if I can stop the killing power of HOME button. Please advise. :) – aXqd Jul 01 '11 at 16:45
  • If saving fails, there's not much you can do. You can't rely on the user to always press your button, any number of other things might happen to kill your app, such as the user pressing the home button, running out of battery, the user killing your app manually, etc. Don't worry about extremely unlikely situations that you can't do anything about, and concentrate on making your app work well in normal use. – Jim Jul 01 '11 at 16:52
  • Specifically, in this case, the big SAVE includes some extra work. If it fails, I need to ask users to try again. This is not common, but it is NOT unlikely either. And as I said, when it happens, users lost their data without notice. Hence the 2nd solution is not adequate. I think this is valid justification for exiting my app programatically. Even so, I agreed with you upon 'No, I very much doubt that Apple will let you have a "save and exit" button. It goes completely against the platform conventions and directly contradicts Apple's HIG'. – aXqd Jul 02 '11 at 02:24
  • What kind of extra work? Can't you simply save the data without doing the extra work and do it the next time the app loads? It's very difficult to suggest alternatives when you won't say what it is you are doing. – Jim Jul 02 '11 at 17:30
  • Sorry, missed your last msg. We are doing exactly as you suggested, a.k.a. doing the extra work next time the app loads. Thanks anyway. – aXqd Sep 04 '11 at 12:09
1

Why don't you try just saving automatically all the time? You could save to a temp directory and then at exit do a file move operation. This would probably be much faster than your current save operation which sometimes fails.

jaminguy
  • 25,840
  • 2
  • 23
  • 21
  • Thanks for you answer. We are still supporting some old devices, which is not that good at performance. In fact, we have some processing steps before the big SAVE. If that processing fails, I let SAVE fail too. – aXqd Jul 01 '11 at 16:15