您的位置:首页 > 移动开发

app之间的跳转,查看URL的端口号,主机信息

2016-04-05 16:27 471 查看
//查看Url的状态

- (void)aboutUrl{

* AppTwo表示要跳转到的APP的URL Schemas

* 需要在AppTwo的APP的info--->URLTypes下面配置URL Schemas为AppTwo,不能有下划线

* "://"是固定写法,URL才回被认可

* 后面的str是要传给下一个app的参数

//跳转到对应App

//AppTwo://表示目的应用程序的url

//123这是给下个应用传递参数

NSString *toPath = [NSString stringWithFormat:@"AppTwo://%@",@"123"];

NSURL *toUrl = [NSURL URLWithString:toPaht];

//打开程序

//openURL表示启动别的应用程序

[[UIApplication sharedApplication]openURL:toUrl];

NSURL *url = [NSURL URLWithString:toPath];

[[UIApplication sharedApplication] openURL:url];

//协议

NSLog(@"scheme:%@", [url scheme]);

//url的一部分

NSLog(@"relativeString:%@", [url relativeString]);

//完整的url字符串(绝对路径)

NSLog(@"absoluteString:%@", [url absoluteString]);

//主机

NSLog(@"host:%@", [url host]);

//端口

NSLog(@"port:%@", [url port]);

//路径search

NSLog(@"path:%@", [url path]);

//search

NSLog(@"pathComponents:%@", [url pathComponents]);

//参数id

NSLog(@"query:%@", [url query]);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: