好吧,我在的iMessage應用程序的工作,我試圖從選定的消息這裏 - 我已經成功獲取/在查詢只發送1值解析超過1個網址查詢項目:如何在Swift中傳遞和獲取多個URLQueryItems?
override func willBecomeActive(with conversation: MSConversation) {
// Called when the extension is about to move from the inactive to active state.
// This will happen when the extension is about to present UI.
if(conversation.selectedMessage?.url != nil) //trying to catch error
{
let components = URLComponents(string: (conversation.selectedMessage?.url?.query?.description)!)
//let val = conversation.selectedMessage?.url?.query?.description
if let queryItems = components?.queryItems {
// process the query items here...
let param1 = queryItems.filter({$0.name == "theirScore"}).first
print("***************=> GOT IT ",param1?.value)
}
}
當我只有1價值,只是通過打印conversation.selectedMessage?.url?.query?.description
我得到一個可選的1值,這是很好的。但與多個我不能找到一個乾淨的方式來獲得特定的值的關鍵。
對於給定的iMessage鍵,解析URLQueryItem
的正確方法是什麼?