无法访问 table 视图单元格中的 Struct 中的值。阅读下面屏幕截图中描述的代码
Cannot access to the values in Struct in a table view cell. Read the described code in the screenshot below
enter image description hereScreenshot of error 我正在从 tableviewcell class 中的结构访问值,我想要结构中的值来进行 api 调用。
你的错误是
Can not subscript [Section] with index of type (item).type
是这条线
let item: Item = sectionData[item]
说明在数组下标时不能使用项类型值。
您需要传递一些索引,即一些 Int
值
使用适当的索引更新您的代码
let item: Item = sectionData[indexOfSectedRow]
希望对您有所帮助。
enter image description hereScreenshot of error 我正在从 tableviewcell class 中的结构访问值,我想要结构中的值来进行 api 调用。
你的错误是
Can not subscript [Section] with index of type
(item).type
是这条线
let item: Item = sectionData[item]
说明在数组下标时不能使用项类型值。
您需要传递一些索引,即一些 Int
值
使用适当的索引更新您的代码
let item: Item = sectionData[indexOfSectedRow]
希望对您有所帮助。