7 Powerful Keywords to Streamline Your Swift Code

Swiftos
Geek Culture
Published in
6 min readMar 11, 2021

--

Photo by Jon Tyson on Unsplash

Hi iOS Developers,

In one of my previous articles, I discussed some powerful protocols to take your code to the next level. Today, I’m going to tell you about some handy keywords to streamline your code. Please check out my previous article if you are interested, Long story short, let’s jump right into it.

fallthrough

In general, the switch statement only executes one case. If we want to continue the execution to the next case, we can use the fallthrough keyword. Here’s an example:

Let’s say we’re developing a weather app. We need to check the authorization status. Based on what we find out about status, here’s what we’ll do:

  1. If the user is suspicious, we will sign him/her out;
  2. If the user is unauthorized, we will sign him/her in, retrieve the location and the weather;
  3. If the user is authorized, we will retrieve the location and the weather.

--

--

Swiftos
Geek Culture

I publish short iOS development tutorials on a weekly basis. For all content, head over to: https://www.patreon.com/Swiftos