1 获取特定查询的价值
看一下这个字符串url示例。不要点击,这只是一个例子
http://www.example.com/landing/index?uid=L011403&token=clZAAWxBL1SP55qpR02FsDesY&success=1&souce=http://fb.com/swift&flag=4
首先,我们先找一下“success”
import Foundation
let sampleStringUrl = "http://www.example.com/landing/index?uid=L011403&token=clZAAWxBL1SP55qpR02FsDesY&success=1&souce=http://fb.com/swift&flag=4"
// Create URLComponent object based on string url
// this will return option value, so we use "if let .." to avoid nil object
if let urlComponent = URLComponents(string: sampleStringUrl) {
// queryItems is an array of "key name" and "value"