Restarting your own application is a tricky thing to do, because you can’t tell yourself to start up when you aren’t running. Here is one solution, use NSTask to run a very short script that you can embed right in your Objective-C code:
kill -9 YourPID
open PathToYourApp
Something to be aware of, kill -9 will immediately terminate your application, without going through the usual applicationWillTerminate: business that happens when an application quits more gracefully.
- (void) restartOurselves
{
//$N = argv[N]
NSString *killArg1AndOpenArg2Script = @”kill -9 $1 \n open \”$2\”";
//NSTask needs its arguments to be strings
NSString *ourPID = [NSString stringWithFormat:@”%d”,
[[NSProcessInfo processInfo] processIdentifier]];
//this will be the path to the .app bundle,
//not the executable inside it; exactly what `open` wants
NSString * pathToUs = [[NSBundle mainBundle] bundlePath];
NSArray *shArgs = [NSArray arrayWithObjects:@”-c”, // -c tells sh to execute the next argument, passing it the remaining arguments.
killArg1AndOpenArg2Script,
@”", //$0 path to script (ignored)
ourPID, //$1 in restartScript
pathToUs, //$2 in the restartScript
nil];
NSTask *restartTask = [NSTask launchedTaskWithLaunchPath:@”/bin/sh” arguments:shArgs];
[restartTask waitUntilExit]; //wait for killArg1AndOpenArg2Script to finish
NSLog(@”*** ERROR: %@ should have been terminated, but we are still running”, pathToUs);
assert(!”We should not be running!”);
}
WARNING: don’t make the same mistake that I did and test restartOurselves without some kind of guard to keep your application from restarting forever. It is very difficult to kill such a beast, because whenever it starts up it takes keyboard focus away from what you are doing…. well I’m sure you get the idea.
- (BOOL) weHaveRunBefore {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
BOOL weHaveRunBefore = [prefs boolForKey:@”weHaveRunBefore”];
[prefs setBool:YESs forKey:@”weHaveRunBefore”];
[prefs synchronize];
return weHaveRunBefore;
}
This New York Times article explains how dozens of people in several states contracted salmonella after they mistakenly microwaved raw chicken, instead of throughly cooking it in an oven.
According to the Department of Agriculture, the dishes included breaded or pre-browned chicken breasts, some of them stuffed with vegetables or sold as “chicken Kiev” and “chicken cordon bleu.” The appearance of the food led people to assume that the chicken breasts were thoroughly cooked, even though they were still raw or undercooked inside.
According to the USDA alert (emphasis mine)
Although many of these stuffed chicken entrees were labeled with instructions identifying the product was uncooked and did not include microwave instruction for preparation, individuals who became ill did not follow the cooking instructions and reportedly used a microwave to prepare the product.
This is what I would call a failure of labeling. Showing a fully-cooked chicken cordon bleu is clearly more appetizing then a picture of raw meat; but it is not a totally accurate depiction of what’s in the box. I wouldn’t call it unethical in and of itself, but the embellishment should have been offset with a clear indication that the meat was raw. Especially since it’s impossible to tell if a frozen piece of fully-breaded chicken is raw or cooked. If the USDA alert is taken at face value, then only “many”, not all, of the frozen chicken was labeled as raw. That does not seem right.
Unfortunately, no brands were named in the alert. So I can’t comment on the actual designs.
…the average American consumes so much energy every day, it would take 200 slaves to reproduce his lifestye. Modern industry makes such luxury possible.
At least according to my television. It’s nice to live in the future.
There are lots of people who strongly suggest that you should do your development in public. It is part of the “release early and often” concept. But I also believe that this concept is not effective in developing great ideas because it is limiting. The minute that you get real customers involved, their needs become much more pedestrian. They will yell loudly about things that may be important to their use of the product, but they will rarely yell about some new game-changing concept. In fact they will resist radical change and rethinking because it messes with their now committed workflow. And now you are comitted to supporting them. So as I see it you should strongly consider whether you have enough meat on your conceptual bone before you decide to release publicly. Because when you get users involved, it is the equivalent of putting the saw and the screwdriver down and grabbing the sand paper. There will likely be few additional big ideas after that point.
-Hank Williams
The master engravers Baldwin Bredell and Arthur Taylor were so adept at these techniques that in the 1890s they were actually able to make a photoengraving plate and print bills in their prison cell, using smuggled tools, chemicals from the prison laundry, extracts from fruits and flowers brought by visitors, and sunlight. At the time, they were awaiting trial for producing copies of $100 bills that were so good that the government had been forced to recall the entire issue upon which they were based. Impressed with their skill, the chief of the Secret Service helped set the men up in legitimate businesses after their release.
Invention & Technology Magazine
…there is actual precedent for creating value for people with technology. Think of word processors, databases, spreadsheets, web browsers, web publishing, search engines, email, etc. Social media is the first major computing revolution that as far as I can tell, has produced essentially nothing.
But the social media craze is perfectly fitting in a society where producing nothing has been in fashion for years. Mortgages without credit. Profit without product. Riches without risk. Oops.
-Hank Williams
And here’s Marlon Brando reading The Hollow Men in Apocalypse Now.
Money can’t buy you love, but love can bring you money. In software the only sustainable way to earn money is by first creating love, and then hoping that some folks want to demonstrate that love with their dollars.
…. Everything should be shareware to be tried and tested until its value is proven and the love-meter swings open the wallet. If I were to pass on some music or a piece of code I become a vector of word of mouth viral marketing, the best kind, the kind that money can’t buy.
-Daniel James
Here’s a case where Windows 98 “beats” out Mac OS X.
CFShow(coreFoundationThingy) will print out a description of coreFoundationThingy to the console. Output looks something like:
{value = w:1186.000000 h:687.000000 type = kAXValueCGSizeType}
If NSLog() is printing something out as an NSCFType, try CFShow().
…joyful playful exploration is critical to learning. Rote learning and memorization is less effective.
…
I believe that a big part of the reason that Apple has been successful is that they figured out long ago that their products had to have the elements of joyful exploration that are the hallmarks of great toys
-Hank Williams
The short article is worth reading.