URL解析

作者: 点滴86 | 来源:发表于2017-03-17 16:11 被阅读47次

一个URL示例https://johnny:p4ssw0rd@www.example.com:443/diandi86/gogo?id=123456&name=Jack#reference
代码如下

NSString *strUlr = @"https://johnny:p4ssw0rd@www.example.com:443/diandi86/gogo?id=123456&name=Jack#reference";
    self.urlLabel.text = strUlr;
    NSURL *tempUrl = [NSURL URLWithString:strUlr];
    self.schemeLabel.text = [NSString stringWithFormat:@"scheme:%@",[tempUrl scheme]];
    self.userLabel.text = [NSString stringWithFormat:@"user:%@",[tempUrl user]];
    self.passwordLabel.text = [NSString stringWithFormat:@"password:%@",[tempUrl password]];
    self.hostLabel.text = [NSString stringWithFormat:@"host:%@",[tempUrl host]];
    self.portLabel.text = [NSString stringWithFormat:@"port:%@",[tempUrl port]];
    self.pathLabel.text = [NSString stringWithFormat:@"path:%@",[tempUrl path]];
    self.queryLabel.text = [NSString stringWithFormat:@"query:%@",[tempUrl query]];
    self.fragmentLabel.text = [NSString stringWithFormat:@"fragment:%@",[tempUrl fragment]];

主界面如下

1.png

点击URL解析,跳转到URL解析界面
URL解析界面如下

2.png

相关文章

网友评论

      本文标题:URL解析

      本文链接:https://www.haomeiwen.com/subject/thwenttx.html