=====工程A=====
0. 建立工程A, 先调出URL Types
- 添加一个叫URL types的键值。
- 给其下的Item 1添加一个URL identifier,格式为Reverse Domain Name:com.mycompany.myapp。
- 再加一个URL Scheme,然后给它定义一个值,任意字符串。比如:myapp。

2. 在工程A的AppDelegate.m里加入以下系统方法:
(这个方法会捕获调用本工程的程序传递过来的URL identifier文本)
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL*)url
{
// 处理传递过来的参数
UIAlertView *alertView;
NSString*text = [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
alertView = [[UIAlertView alloc] initWithTitle:@"Text"
message:text
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
return YES;
}
{
// 处理传递过来的参数
UIAlertView *alertView;
NSString*text = [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
alertView = [[UIAlertView alloc] initWithTitle:@"Text"
message:text
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
return YES;
}
====工程B=====
3. 建立工程B, 添加调用语句:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"myapp://foo=444bar=222"]];
4. 编译运行工程B, 结果是:
B启动->A启动->A弹出Alert:
另外:
0. 从结果看出app的地址构成是: URL Scheme://URL identifier
1. 单用URL Scheme 即可打开程序, 即URL identifier是可选的
2. myapp://后面的字 可以为点”.”和等号”=” 不可以为空格和问号
3. stackoverflow上有很多人指出这是apple禁止的功能, 所以请谨慎使用, 但如果是客户问”设备能力”这方面的问题, 那么答案是”可以”, 但 不建议那么做.