Skip to content

Instantly share code, notes, and snippets.

@hanfengs
Created July 16, 2019 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanfengs/d589f69e098e1b36bc884356e48df321 to your computer and use it in GitHub Desktop.
Save hanfengs/d589f69e098e1b36bc884356e48df321 to your computer and use it in GitHub Desktop.
[NSURL 的解析和编码]
//https://quxue-data.oss-cn-beijing.aliyuncs.com/scene_course/reading/baowei/reading12-3-73.json
NSURL *url = [NSURL URLWithString:jsonUrl];
NSLog(@"Scheme: %@", [url scheme]);//https
NSLog(@"Host: %@", [url host]);//https
NSLog(@"Port: %@", [url port]);//null
NSLog(@"Path: %@", [url path]);//scene_course/reading/baowei/reading12-3-73.json
NSLog(@"Relative path: %@", [url relativePath]);//scene_course/reading/baowei/reading12-3-73.json
/*
Path components as array: (
"/",
"scene_course",
reading,
baowei,
"reading12-3-73.json"
)
*/
NSLog(@"Path components as array: %@", [url pathComponents]);
NSLog(@"Parameter string: %@", [url parameterString]);//null
NSLog(@"Query: %@", [url query]);//null
NSLog(@"Fragment: %@", [url fragment]);//null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment