0

enter image description hereScreenshot of error I am accessing the value from a structure in tableviewcell class , I wanted the value from the structure for making the api call .

Vishav
  • 37
  • 8
  • You should update your question with the actual code instead of the screenshot. It will help others to reproduce the errors and can helps you find the solution quickly. – Bhavin Kansagara Mar 29 '19 at 08:36

1 Answers1

0

Your error is

Can not subscript [Section] with index of type (item).type

is for this line

let item: Item = sectionData[item]

It explains that you cannot use item type value while subscripting on array.

You will need to pass some Index, i.e some Int value

Update your code with some proper index

let item: Item = sectionData[indexOfSectedRow]

Hope it helps.

Bhavin Kansagara
  • 2,866
  • 1
  • 16
  • 20
  • I am in tableviewcell class , I am just increasing and decreasing the quantity in a cart , I can not find the index – Vishav Mar 29 '19 at 08:53
  • Without looking at more code, it is hard to suggest more. But you can take a var myIndexPath: IndexPath? in your custom TableViewCell and in cellForRowAt, you can set cell.myIndexPath = indexPath and can use that. – Bhavin Kansagara Mar 29 '19 at 09:19
  • @CODE_APP You can find indexPath from Cell class as well. check this - https://stackoverflow.com/questions/40437550/how-can-i-get-indexpath-row-in-cell-swift/40437779 – Amir Khan Mar 29 '19 at 09:45
  • I am click a button in cart to increase and decrease the quantity , so on button of click I want to update the quantity so wanted the structure parameter to pass in ... – Vishav Mar 29 '19 at 10:16