How do I convert url.query to a dictionary in Swift?

前端 未结 6 1405
不知归路
不知归路 2021-02-09 02:06

I have a URL coming in to the AppDelegate method:

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) ->         


        
6条回答
  •  猫巷女王i
    2021-02-09 02:37

    Use .first(where:)

            guard let query = components.queryItems else {
                return
            }
            
            guard let accessToken = query.first(where: { $0.name == "access_token" }) else {
                return
            }
    

提交回复
热议问题