One of the formatting defaults in Xcode you may want to change is the lack of indenting on switch statements. By default, this is how the parts line up:
switch preferredStatusBarStyle {
case .darkContent:
handleDarkContentStatusBar()
case .lightContent:
handleLightkContentStatusBar()
case .default:
handleDefaultStatusBar()
}
There is a setting in Xcode preferences that will add an indentation before the cases, which can make switch blocks easier to read. To enable this, go to:
- Xcode menu
- Preferences
- Text Editing tab
- Indentation sub-tab.
Xcode will now automatically indent like so:
switch preferredStatusBarStyle {
case .darkContent:
handleDarkContentStatusBar()
case .lightContent:
handleLightkContentStatusBar()
case .default:
handleDefaultStatusBar()
}
Tags: