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 Blog Reader iPhone App Exploring the Master-Detail Template Modifying The Master-Detail Template

Jacob McLaws
Jacob McLaws
1,497 Points

Aligning code

In this video (and others) the code gets lined up in an organized way below each other: @"lskjfld", @"BLAH BLAH BLAH", @"jacob is cool", nil];

I know it's simple, but can someone please explain how to do that? I always end up with a long unruly string and a mess.

2 Answers

Vanessa Cantero G贸mez
Vanessa Cantero G贸mez
7,376 Points

Just press enter after the comma. Xcode manages the indentation after this. Also, when you have this longs methods, just press enter again after the arguments, for example in:

[[UIAlertview alloc] initWith:a with:b with:c];

Press enter after a, b and c.

John Steer-Fowler
PLUS
John Steer-Fowler
Courses Plus Student 11,734 Points

Hi Jacob,

Good question, this is not necessary, but an extremely helpful thing to learn now as it is good practice for all coding.

What you are referring to is indenting code so it is easier to read. In the video (and most programmers) the Tab Key is used to make an indent when required. At the start of the line you want to indent, press the Tab Key once and it will make one indent you see in the video.

I will give you an example with html, just so you can see it helps you to read any language more efficiently:

<div class="indentpractice">
      <ui>
            <li>This is a list item</li>
            <li>This is another list item</li>
      </ul>
</div>

For each of these indented lines, the Tab Key is pressed at the start of the line. You can do this both before or after you write the lines of code, but it is best to do it before as good practice.

Hope this is what you were looking for

Keep up the good work