let orderID = (responceDictionary as NSDictionary).value(forKeyPath: "result.id") as? String
錯誤: '[AnyHashable:Any]?'不轉換爲「NSDictionary的」Xcode Swift - 任何不可轉換爲NSDictionary
我不完全知道如何從任意投 - >的NSDictionary但作爲一個字符串,它似乎與我試圖拋出錯誤。
let orderID = (responceDictionary as! NSDictionary).value(forKeyPath: "result.id") as? String
以上編譯但使用此引發另一個錯誤:將永遠失敗。
Moltin.sharedInstance().cart.order(withParameters: orderParameters, success: { (responceDictionary) in
let orderID = (responceDictionary as NSDictionary).value(forKeyPath: "result.id") as? String
什麼樣的反應,你在這裏嘗試分析的麻煩。請添加JSON結構。 –
@AdilSoomro我已經添加到問題。 – Owen26