当前位置:网站首页>Swift get URL parameters

Swift get URL parameters

2022-07-08 01:00:00 Sober thinking

swift obtain url Parameters

public extension URL {
    
    var urlParameters: [String: String]? {
    
        guard let components = URLComponents(url: self, resolvingAgainstBaseURL: true),
        let queryItems = components.queryItems else {
     return nil }
        return queryItems.reduce(into: [String: String]()) {
     (result, item) in
            result[item.name] = item.value
        }
    }
}
原网站

版权声明
本文为[Sober thinking]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/189/202207072314139279.html