当我向结构添加一个整数并希望在UITableview中使用时,我收到错误。这是代码:
struct Mijnproducten {
var productname : String!
var prodID : Int!
var productdesc : String!
var productline : [String]!
var expanded : Bool!
init(productname: String, prodID: Int,productdesc: String, productline: [String], expanded: Bool)
{
self.productname = productname
self.prodID = prodID
self.productdesc = productdesc
self.productline = productline
self.expanded = false
}
}
的UITableViewController:
从alamofire请求中检索信息:
for (_, dict) in jsonArray {
let thisObject = Mijnproducten(productname: dict["productname"].string!, prodID: dict["tagID"].int!, productdesc: dict["productdesc"].string!, productline: ["Description", "History", "Transfer"], expanded: false )
self.mijnproducten01.append(thisObject) }
在这个函数中我使用变量:
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let Cell = tableView.dequeueReusableCell(withIdentifier: "labelCell") as! RowTableViewCell
Cell.ProductLine.text = mijnproducten01[indexPath.section].productline[indexPath.row]
var Tags = String(mijnproducten01[indexPath.section].prodID[indexPath.row])
Cell.UUID.text = Tags
return Cell
}
错误在该行显示:
var Tags = String(mijnproducten01[indexPath.section].prodID[indexPath.row])