Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.