'__NSDictionaryI'(0x108fda238)到'NSArray'(0x108fd9dd8)。 get方法中的(lldb)错误

时间:2018-03-08 07:03:02

标签: swift swift3

这是我的代码:

  override func viewDidLoad() {
    super.viewDidLoad()
    tableview.delegate = self
    tableview.dataSource = self

    Alamofire.request("http://********************").responseJSON { (response) in
        //getting json data
        if let json  = response.result.value {

            //converting json to NSArray

            **let GiftArray : NSArray = json as! NSArray** 

            //traversing through all elements of the array

            for i in 0..<GiftArray.count {

                //adding gift values to the gift list
                self.GiftHer.append(gifther(Productname: ((GiftArray[i] ) as AnyObject).value(forKey: "name") as? String, DescriptionData: ((GiftArray[i] ) as AnyObject).value(forKey: "description") as? String, Price: ((GiftArray[i] ) as AnyObject).value(forKey: "price") as? String, Currencytype: ((GiftArray[i] ) as AnyObject).value(forKey: "cost_currency") as? String, Companyname: ((GiftArray[i]) as AnyObject).value(forKey: "company_name") as? String, ImagesUrl: ((GiftArray[i] ) as AnyObject).value(forKey: "master_variant_images") as? String))
            }

            self.tableview.reloadData()
        }
    }

    self.tableview.reloadData()
}

我正在将json转换为nsarray然后我得到了以下错误

  

无法将类型'__NSDictionaryI'(0x108fda238)的值转换为   'NSArray'(0x108fd9dd8)。

0 个答案:

没有答案