Parsing JSON returns nil

后端 未结 1 766
半阙折子戏
半阙折子戏 2020-12-22 13:40

I\'m using this code to order a product place in the cart. I\'m trying to get the order ID of the order generated. I\'m not too sure what is happening as the \'result\' is t

相关标签:
1条回答
  • 2020-12-22 14:11

    You cannot pass a key path to a key subscription and id is an Int:

    if let resultDictionary = responceDictionary["result"] as? [String:Any],
       let orderID = resultDictionary["id"] as? Int {
           let orderIDString = "\(orderID)"
           print(orderIDString)
    }
    
    0 讨论(0)
提交回复
热议问题