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

Learning the Language Extra Credit

I was trying the extra credit where you had to make an NSArray of colors and then have them print on the label. They finally worked but I found if i typed in the property for the button i drew on my storyboard it wouldn't link up right. I had to actually link the button and have it create the property. Can anyone explain to me why I couldn't just type the code myself?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Sorry your question is not clear. Can you either paste your code or explain what you mean by: " if i typed in the property for the button i drew on my storyboard it wouldn't link up right"

4 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

So your question is:

It seems that if I create a UIButton or UILabel and change the attributes through the storyboard it does not get written out in code or at least not code that I see. Is that correct?

You are partially right. The Storyboard is nothing but an XML file. Interface Builder just provides you with a visual tool to manage the Storyboard. Any attribute you change on your storyboard gets saved to the XML file. When the system draws your view on the screen it parses this XML to figure out which views needs to be drawn along with their attributes / settings.

Is that possible to post the answer for this 'extra credit' question? Been trying to get it right but found difficult.

*if answer is not possible, can you clarify the question a bit more by explaining what [UIColor] objects actually are? Don't really get it from the doc

Thanks!

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

When you create an array you have to provide it with objects:

NSArray *strings = [[NSArray alloc] initWithObjects:@"one",@"two",nil];

Above we declared an array object called strings with two string objects. Similarly, you can create an array of UIColor objects:

NSArray *colors = [[NSArray alloc] initWithObjects:[UIColor redColor],[UIColor blackColor],nil];

can you clarify what you mean

Yes, sorry if i wasn't clear. I think i figured out my problem, but maybe you can answer this question instead. It seems that if I create a UIButton or UILabel and change the attributes through the storyboard it does not get written out in code or at least not code that I see. Is that correct?

correct because its in the storyboard so if a label changes colour it wont show up in our code. but because the method to change the colour was created in the code you can log it then see what the colour is at the moment. hope this helps if so you can top comment. to our journey as developers, cheers.