1、首先我们来创建第一个Single Application,命名为FirstAPP。
2、首先我们来创建第一个Single Application,命名为SecondAPP。
3、分别创建一个点击按钮 添加事件

secondAPP 同理
4、然后编辑FirstAPP 和 SecondAPP的相关信息




注意:Identifier要填写一直
5.然后点击事件触发URL FirstAPP
NSLog(@"执行了点击事件");
NSString *urlStr = @"SecondAPP://";
NSURL *url = [NSURL URLWithString:urlStr];
[[UIApplication sharedApplication]openURL:url];
6.同理SecondAPP
NSLog(@"执行了点击事件");
NSString *urlStr = @"FirstAPP://";
NSURL *url = [NSURL URLWithString:urlStr];
[[UIApplication sharedApplication]openURL:url];
运行两个APP吧 胜利就在眼前。
可耻的分割线-------------------------------------------------------------------------
加个传值吧
1.在FirstAPP 改成为
- (void)clickAction{
NSLog(@"执行了点击事件");
NSString *text = @"myNameIsFirstApp"; 这个就是你要传递的值
NSString *urlStr = [NSString stringWithFormat:@"SecondAPP://%@",text];
NSURL *url = [NSURL URLWithString:urlStr];
[[UIApplication sharedApplication]openURL:url];
}
2.在SecondAPP 的 AppDelegate.m中添加
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;方法
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
// self.rootVC.getString = [[url host]stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"host= %@",url.host);
NSString *urlStr = [[url absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"urlStr:%@",urlStr);
self.rootVC.getString = urlStr;
return YES;
}
打印的结果 host= myNameIsFirstApp urlStr:SecondAPP://myNameIsFirstApp



就这样了 没有了
网友评论