Xavier Rubio Jansana

Xavier Rubio Jansana

Mobile engineer.
Android and iOS.
Scuba diver.

© 2024

Xcode switch tip

Today I’ve found a tip from Google about iOS development, on their “Route 85” Youtube video series. I always code defensively, and adding a default case option is one of the things you usually do on a switch when programming defensively. But in the case they show, this is a bad thing. When you write a switch statement for an enum, Xcode will warn you if you’re missing any value, except if you rule this option out by means of a default. See the video for more information and an example.

Nice tip guys!