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

iOS

Filling multiple labels from one array

I would like to be able to click button1 and fill label1 with a random word from an array, then i would like to click button2 and fill label 2 with a random work from the same array. Thanks

2 Answers

  1. Define an array with words.
  2. use arc4random_uniform(array count) to retrieve random number.
  3. retrieve the word from the array using random number and assign it to the labels.

Sorry. How would I go about doing this?

Sorry. How would I go about doing this?