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 trialChris Stromberg
Courses Plus Student 13,389 PointsHow could I use the button to sequence thru the array of fun facts?
I'm trying to figure out how to use the struct so that when the button is pressed it will sequence thru the array of funFacts[i] .
How could I get the index for the array to increment by pushing the button.
2 Answers
Chris Stromberg
Courses Plus Student 13,389 PointsThanks I figured it out on my own.
Sorry for asking the same question, I tried a search but your question did not show in the results.
var arrayTest = ["Spot 0","Spot 1","Spot 3"] funFactLable.text = arrayTest[i] if i < (arrayTest.count - 1) { println(" (i++)")}else { i = 0 } }
Andres Oliva
7,810 PointsI already answered a similar question before. You may want to check out this post.