Background: if there are two programs a and B (of course you have to write them on your own) and you want to judge whether program B exists on the local machine in program a, start it, A dialog box is displayed at startup. The content of the dialog box is included in program. The background ends. The following is the implementation process.
Implementation:
1. open info in program B. in the plist file, create a key = URL types, create a URL schemes under this file, and set the value after item0 to "MyApp". The MyApp here is random, what do you like. In this way, other programs can use this MyApp to call this program.
2. In the "appdelegate. m" file of program B, assume the following method.
-(Bool) Application :( uiapplication *) Application handleopenurl :( nsurl *) URL {// process the passed parameter uialertview * alertview; nsstring * text = [[url host] stringbyreplacingpercentescapesusingencoding: response]; alertview = [[uialertview alloc] initwithtitle: @ "text" message: Text delegate: Nil cancelbuttontitle: @ "OK" otherbuttontitles: Nil]; [alertview show]; [alertview release]; return yes ;}
This method can be understood at a Glance. If you do not understand it, go to the basic tutorial first! I will not explain it too much here.
In this way, program B is ready. Let's witness a magical moment.
3. In program a, execute the following code where you want to call B.
[[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring: @ "MyApp: // Shenyang bin sub-test"];
If the test exists, it can be started normally. If the test does not exist, no error is reported.
4. Now there is no problem with the startup. If you only need to make a single decision, you can change it to another place.
Bool iscunzai = [[uiapplication sharedapplication] canopenurl: [nsurl urlwithstring: @ "MyApp: // Zhiqiang original"]; If (iscunzai) {// exists} else {// does not exist}
Article Source: http://www.cnblogs.com/zhiqiangsimida/archive/2013/01/19/IOS.html