Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
James McCormack
12,659 PointsSwift TableView with Buttons and Stepper
Hi, been trying to create a table view list with sections and rows. In each row are labels, a stepper to increase values (shown in another label) and an 'add' button.
I've used a customer cell class to hold the outlet and func for stepper and 'add' button
Basically, when the stepper is incremented/decreased the value is stored and displayed within the cell label. When the 'add' button is clicked, the cell 'name' (cell.nameLabel.text) and stepper value are saved to a dictionary "var itemDict = String: String" within the 'add' button function, then added to an array "var orderSummary = Any" in the View class
Problem i have is that I realized this array only exists within the context of each cell, not a global array that holds the dictionary from all cells. When i println() on the ViewClass.orderSummary at the end of the function call I can see that cell being added to the array for that cell only, and the same for other cells.
But a button within the ViewClass that println() the orderSummary shows [].
Any ideas of what I'm missing here? I think i might be approaching the accessing of cell values in the wrong way.
Cheers