Swift 3现在提供了内置方法,可以做个简单的封装:
extension String {
/// 假设string是url,抽取key&value对
func tt_urlQueryDict() -> [String: String] {
var dict = [String:String]()
guard let queryItems = URLComponents(string: self)?.queryItems[......]
iOS从URL中解析query的key&value对
Leave a reply