Re: Seeking a graceful way to end a program
Re: Seeking a graceful way to end a program
- Subject: Re: Seeking a graceful way to end a program
- From: Fritz Anderson <email@hidden>
- Date: Thu, 29 Apr 2010 13:48:54 -0500
On 29 Apr 2010, at 1:31 PM, Paul Johnson wrote:
> I would like to have some guidance on the proper way to 'gracefully'
> terminate a program that cannot proceed, for example, when some
> critical resource can't be created or doesn't exist.
>
> I've look through all my reference books and searched the internet for
> sample code but have come up empty handed. Thanks for your assistance.
Your bad luck probably has to do with the vagueness of what you're asking, compared with the specific failures you want to handle.
iPhone or Mac?
What kind of "critical resource?" A configuration file, code, media... ?
Is it something you expect to find in your application bundle, something over the network, in the file system... ?
Is it something for which you can provide a default or stop-gap substitute, so you can at least survive to put up an alert?
Is it known for its work in the theater?
What kind of "cannot proceed?" Will crash immediately, can't support the user's request, will corrupt data... ?
What, in short, is it?
Off the top of my head, the Right Things are:
* Preflight the availability of the resource, and disable the commands that would require it.
* Back out of the task that resulted in the missing resource, if possible, and post an alert explaining what can't be done, why, and how to fix it.
* If the application can't proceed in any way (not even to the extent of access to commands or preferences that might fix the problem), always post an alert saying so. On the Mac, provide a Quit button. On the iPhone, post an alert explaining the situation, and advise the user to press the Home button; present an inert (empty if necessary) UI if the user dismisses the alert instead.
* Provide some facilities for self-repair, preferably from within application commands or preferences.
* Don't terminate a Mac application without an explanation. The only way to terminate an iPhone application is to call abort(), which I believe could be a reason to reject it from the App Store.
— F
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden