Yeah… Relaunch command doesn’t exits in Cocoa so there is no way that Cocoa-touch will have one and Statistique (The upcoming iPhone app) requires relaunch if you try to free-up the memory due to the allocation of static variables.
So, I had to write my own piece of code that will do that for me and this was a breakthrough…
How can you do such a thing when the bundle path differs from phone to phone? when NSTask doesn’t exits? and system() is ignored?
Ha, there is always a way to do whatever you want, all you need is keep trying…
Enough chatting…
How? Using UIApplication with openURL method and I am not kidding.
Setting your application to have a certain URL. Google it you will find plenty of information out there. CFBundleURLType and CFBundleURLSchemes set them let’s say with the name “stat”.
All you need to do to open your application is:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”stat:”]];
This will launch your application. So on how to restart, is pretty obvious but it doesn’t work. You need to add one more line
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”http:”]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”stat:”]];
Just use the above code, first call a url to open safari and then to open your application. Safari won’t even be displayed so there is nothing to worry about. ;)