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 Creating a Data Model Creating a Data Collection

What is wrong with my Code, It seems to match the videos exactly... but doesn't work

3 Answers

Patrick Cooney
Patrick Cooney
12,216 Points

Treehouse code is using a constant and your code is using a variable. Idk if this is for a code challenge or just your code for the app. Can you give us a little more info? Also, it helps us if in the future you post the code directly in the forum. You can format it by putting three ` marks at the beginning on their own line then again at the end on their own line.

I agree with Patrick, the fact that it's a constant and yours is a variable is a real difference. Additionally what about your code isn't working?

Yes. I figured it out. You created an immutable array by declaring the array using 'let'. Since this array is immutable, the error occurs when you attempt to change the array by passing the label's String value into this array that cannot be changed. Use var to declare the array as "mutable".

Looks like your code is missing a curly brace at the end.

Thanks for the advice, But doesn't seem to make a difference, I'll try cross referencing my previous code with the videos again.