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

来源:互联网 发布:青岛网络在线问政 编辑:程序博客网 时间:2024/06/10 00:14

//查看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]);
}
0 0
原创粉丝点击