以前写代码请求接口是只知道接口地址用字符串拼接,今天突然发现NSURL有很多强大的属性:
(lldb) po url.absoluteString
http://ilearnzz.zzedu.net.cn/m/phonesay/save.action
(lldb) po url.relativePath
/m/phonesay/save.action
(lldb) po url.relativeString
http://ilearnzz.zzedu.net.cn/m/phonesay/save.action
(lldb) po url.baseURL
nil
(lldb) po url.absoluteURL
http://ilearnzz.zzedu.net.cn/m/phonesay/save.action
(lldb) po url.scheme
http
(lldb) po url.resourceSpecifier
//ilearnzz.zzedu.net.cn/m/phonesay/save.action
(lldb) po url.host
ilearnzz.zzedu.net.cn
(lldb) po url.port
nil
(lldb) po url.user
nil
(lldb)