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 Swift Basics (retired) Control Flow Switch Statement

Samuel Seidel
Samuel Seidel
1,481 Points

What's up with the IDE's spacing for the switch statement?

switch something {
     case 1:

instead of

switch something {
case 1:

2 Answers

Done by convention to improve readability and ease of maintaining the code. However, if desired, your IDE should have a configuration option somewhere where you can customize indentation to your liking.

Samuel Seidel
Samuel Seidel
1,481 Points

I actually meant, that, xcode is choosing the second example for formatting. Shouldn't it be doing it the first way?

Apologies for misinterpreting. I did see this discussion, which may provide some background on xcode formatting.