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 Build a Simple iPhone App with Swift Improving Our User Interface Adding a Pop of Color

return colorsArray[randomNumber] leads to "breakpoint"

I have added the ColorWheel struct and view.backgroundColor = colorWheel.randomColor() to ViewController.

When I try to simulate the app on an iPhone 5S, the app does not appear to work and I receive the following message:

self FunFacts.ColorWheel
colorsArray [UIColor] 7 values
unsignedArrayCount UInt32 7 7 value Builtin.Int32 7 7 unsignedRandomNumber UInt32 1 1 value Builtin.Int32 1 1 randomNumber Int 1 1 value Builtin.Word 1 1

Chris Shaw
Chris Shaw
26,676 Points

Hi Qin,

It would appear your attempting to access an index that is higher than the length of your array, could you please post the code for your randomColor method and your random colours array.