iOS Url引數拆分

ZY_FlyWay發表於2017-08-22
前言:筆記,自己看。

Scheme  Url


列印程式碼:

-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{
    
    NSLog(@"%@",url.description);
    NSLog(@"%@",url.absoluteString);
    NSLog(@"%@",url.relativeString);
    NSLog(@"%@",url.scheme);
    NSLog(@"%@",url.resourceSpecifier);
    
    
    NSLog(@"%@",url.description);
    NSLog(@"%@",url.host);
    NSLog(@"%@",url.port);
    NSLog(@"%@",url.user);
    NSLog(@"%@",url.password);
    NSLog(@"%@",url.path);
    NSLog(@"%@",url.fragment);
    NSLog(@"%@",url.parameterString);
    NSLog(@"%@",url.query);
    NSLog(@"%@",url.relativePath);
    
    
    return YES;
}


Scheme Url:

zyurl://TargetA/Action/type?name=zhangyu




列印結果:


2017-08-22 10:50:48.420115+0800 URLParamsDemo[8874:411040] zyurl://TargetA/Action/type?name=zhangyu

2017-08-22 10:50:48.420361+0800 URLParamsDemo[8874:411040] zyurl://TargetA/Action/type?name=zhangyu

2017-08-22 10:50:48.420999+0800 URLParamsDemo[8874:411040] zyurl://TargetA/Action/type?name=zhangyu

2017-08-22 10:50:48.421141+0800 URLParamsDemo[8874:411040] zyurl

2017-08-22 10:50:48.421724+0800 URLParamsDemo[8874:411040] //TargetA/Action/type?name=zhangyu

2017-08-22 10:50:48.421894+0800 URLParamsDemo[8874:411040] zyurl://TargetA/Action/type?name=zhangyu

2017-08-22 10:50:48.422295+0800 URLParamsDemo[8874:411040] TargetA

2017-08-22 10:50:48.422519+0800 URLParamsDemo[8874:411040] (null)

2017-08-22 10:50:48.423358+0800 URLParamsDemo[8874:411040] (null)

2017-08-22 10:50:48.424640+0800 URLParamsDemo[8874:411040] (null)

2017-08-22 10:50:48.425456+0800 URLParamsDemo[8874:411040] /Action/type

2017-08-22 10:50:48.426119+0800 URLParamsDemo[8874:411040] (null)

2017-08-22 10:50:48.427117+0800 URLParamsDemo[8874:411040] (null)

2017-08-22 10:50:48.427617+0800 URLParamsDemo[8874:411040] name=zhangyu

2017-08-22 10:50:48.428053+0800 URLParamsDemo[8874:411040] /Action/type



分析有用的引數:

    

scheme:獲取scheme

resourceSpecifier:獲取scheme剩下的那部分

path:路徑

query:條件引數




請求url

列印結果:



2017-08-22 10:56:31.550373+0800 URLParamsDemo[9830:453299] https://passport.csdn.net/account/login?ref=toolbar

2017-08-22 10:56:31.550614+0800 URLParamsDemo[9830:453299] https://passport.csdn.net/account/login?ref=toolbar

2017-08-22 10:56:31.550723+0800 URLParamsDemo[9830:453299] https://passport.csdn.net/account/login?ref=toolbar

2017-08-22 10:56:31.550826+0800 URLParamsDemo[9830:453299] https

2017-08-22 10:56:31.551019+0800 URLParamsDemo[9830:453299] //passport.csdn.net/account/login?ref=toolbar

2017-08-22 10:56:31.551200+0800 URLParamsDemo[9830:453299] https://passport.csdn.net/account/login?ref=toolbar

2017-08-22 10:56:31.551333+0800 URLParamsDemo[9830:453299] passport.csdn.net

2017-08-22 10:56:31.551460+0800 URLParamsDemo[9830:453299] (null)

2017-08-22 10:56:31.551602+0800 URLParamsDemo[9830:453299] (null)

2017-08-22 10:56:31.551723+0800 URLParamsDemo[9830:453299] (null)

2017-08-22 10:56:31.551830+0800 URLParamsDemo[9830:453299] /account/login

2017-08-22 10:56:31.551947+0800 URLParamsDemo[9830:453299] (null)

2017-08-22 10:56:31.552124+0800 URLParamsDemo[9830:453299] (null)

2017-08-22 10:56:31.552415+0800 URLParamsDemo[9830:453299] ref=toolbar

2017-08-22 10:56:31.552619+0800 URLParamsDemo[9830:453299] /account/login



相關文章