But to get back to the conversation that prompted this thought, the same thing could be done with a .dmg; instead of requesting to move itself when a program finds itself unzipped in ~/Downloads, a program could prompt to copy itself to the Applications folder and relaunch from there if it finds itself running from within its disk image. To imagine the dialog, the buttons would be "Copy" (default), "Copy, then Eject and Trash this Image" (for convenience), and "Run from Here" (or perhaps not—there's no really good reason to include it.) You don't have to include the decision between "Copy and Run" or "Just Copy" because the program is already "running" (from the user's perspective); they double-clicked it, didn't they?<p>But because they see the program as "running" from inside the image, they might try to launch the program <i>again</i> from within the .dmg after it had already been copied (if they didn't choose the Trash Image option.) Thus, the program should probably check for a copy of itself in /Applications and exec(3) it if it exists <i>and is the same version</i>, to avoid the lag of re-installing on every start. Though, since you want to kindly escort the users away from the .dmg, it might be better to present another dialog with the options "Run from /Applications" and "Copy Again" (to overwrite the old app—in case of a bad install or somesuch), giving them a small speedbump and a hint about where to find their app. The we-already-did-this dialog could even offer to automatically add an alias of the app to the Desktop or the Dock, "so you won't have to see this again."
Cool stuff, much appreciated.<p>I notice that the code contains the use of 'goto' to handle an error condition. Seems clean.<p>Being somewhat of a intermediate programmer I've always read to stay away from 'goto'. Anyone care to comment on the use of it in Objective-C?
AppTrap detects when apps are trashed and asks if the user would like to trash prefs as well. Very nice solution, way better than AppZapper.<p><a href="http://onnati.net/apptrap/" rel="nofollow">http://onnati.net/apptrap/</a><p>Don't see whey we can't write a project that solves this problem on a general level with a similar method. When a .app appears in specified folders ask to move it to an applications folder. Watched folders default to ~/Desktop and ~/Downloads and the app folder defaults to /Applications.
Objective C or regular c gotos represent logic jumps which are hard to track by tools and humans.Debugging is difficult when code conditionally jumps around blocks instead of following a flow pattern easily discenible by reading the code. If good code is poetry code that uses gotos are google translations of poetry :-).Technically sound , emotionally funny