不能使用 [String] 类型的下标
cannot subscript of type [String]
我在以下时间收到此错误:
cell.naamItem = VragenInformatie[indexPath.section][indexPath.row][0]
我在同一个 class:
var VragenInformatie: [[[String]]] = [[[]]]
这就是数组的样子:
var VragenInformatie: [[[String]]] = [[["Spelletjeskamer",""],["Keuken",""],["Garage",""],["Binnenplaats",""],["Zitkamer",""],["Slaapkamer",""],["Studeerkamer",""],["Eetkamer",""],["Badkamer",""]],[["De Wit",""],["Pimpel",""],["Blaauw van Draet",""],["Roodhart",""],["Groenewoud",""],["Van Geelen",""]],[["Loden pijp",""],["Pistool",""],["Engelse sleutel",""],["Dolk",""],["Touw",""],["Kandelaar",""]]]
我真的不知道这里的问题是什么,我也不知道下标的真正含义
有人可以给点建议吗?
我敢打赌你的 naamItem
是 UILabel 或类似的东西,而你忘记附加“.text”。如果我的理论是正确的,您的代码应该如下所示:
cell.naamItem.text = VragenInformatie[indexPath.section][indexPath.row][0]
在 naamItem
不是 UILabel、UITextView 或 UITextField 的任何其他情况下,您应该确保 naamItem
的类型为 String
。
我在以下时间收到此错误:
cell.naamItem = VragenInformatie[indexPath.section][indexPath.row][0]
我在同一个 class:
var VragenInformatie: [[[String]]] = [[[]]]
这就是数组的样子:
var VragenInformatie: [[[String]]] = [[["Spelletjeskamer",""],["Keuken",""],["Garage",""],["Binnenplaats",""],["Zitkamer",""],["Slaapkamer",""],["Studeerkamer",""],["Eetkamer",""],["Badkamer",""]],[["De Wit",""],["Pimpel",""],["Blaauw van Draet",""],["Roodhart",""],["Groenewoud",""],["Van Geelen",""]],[["Loden pijp",""],["Pistool",""],["Engelse sleutel",""],["Dolk",""],["Touw",""],["Kandelaar",""]]]
我真的不知道这里的问题是什么,我也不知道下标的真正含义
有人可以给点建议吗?
我敢打赌你的 naamItem
是 UILabel 或类似的东西,而你忘记附加“.text”。如果我的理论是正确的,您的代码应该如下所示:
cell.naamItem.text = VragenInformatie[indexPath.section][indexPath.row][0]
在 naamItem
不是 UILabel、UITextView 或 UITextField 的任何其他情况下,您应该确保 naamItem
的类型为 String
。