NSURL

2021. 4. 8. 15:25개발자료/iOS


반응형

# NSURL 생성

NSString *strUrl = @"https://johnny:p4ssw0rd@www.example.com:443/script.ext;param=value?query=value#ref";
NSURL *url = [NSURL URLWithString:strUrl];
var strUrl = "http://someurl.com/something"
var url = URL(string: strUrl)
var domain = url?.host

 

# NSURL 객체 구조

https://johnny:p4ssw0rd@www.example.com:443/script.ext;param=value?query=value#ref

Component Value
scheme https
user johnny
password p4ssw0rd
host www.example.com
port 443
path script.ext
pathExtension ext
pathComponents ["/", "script.ext"]
parameterString param=value
query query=value
fragment ref

 

※ NSURL 객체에 대해 쉽게 이해할수 있는 이미지가 있어서 올립니다.

http://macoscope.com/blog/nsurl-cheat-sheet/#more

 

반응형