Software Dev

A Case For Force-Unwraping! Optionals in Swift

This topic came up at work last week, with lots of different opinions on how to deal with optionals, so I was happy to see a clear opinion here.

๐Ÿ‘‰ The Danger of Playing it Safe

For any non-programmers reading this, a force-unwrap means that if your app comes across a value that just simply doesn’t exist at all โ˜, then let the app crash right then and there ๐Ÿ’ฅ.

This article distinguishes between development, where it’s okay (and in sometimes encouraged) to crash, and production, where it’s never okay. I like the case here for avoiding poisoned app states that can occur with nil values. Just die already, already! ๐Ÿคท๐Ÿปโ€โ™‚๏ธ This article basically says that some development crashes are good because they expose problems, and to take a more aggressive approach with force unwrapping.

So be assertive with forced unwrapping. If there is no case where the optional should ever be nil, force unwrap

I think I’ll start taking more chances with force unwrapping and point to this article next time it comes up in a code review. ๐Ÿ˜‰

Via iOS Dev Weekly.

Software Dev

Unofficial Sandwiches

I love the idea and name of this project.

Apple demonstrated how to build an app with SwiftUI by doing a detailed walk-through a Sandwiches app.

๐Ÿ‘‰ Introduction to SwiftUI

But they didn’t give you the code! I guess thatโ€™s because they want you to write it yourself. ๐Ÿคท๐Ÿปโ€โ™‚๏ธ

Still, here is a working unofficial version of the Sandwiches app developed to help you along.

๐Ÿ‘‰ GitHub: Unofficial Sandwiches

Via iOS Dev Weekly.

Software Dev

Fun Xcode Search Tip

Here’s a great tip for anyone using Xcode: when you’re going through a list of search results, you can just delete the items you’re not interesting in. ๐Ÿคฏ It’s so weirdly simple and obvious but surprising.

Via iOS Dev Weekly.

Software Dev

Scroll Hitch Rate

Xcode 12 is adding a new metric to objectively track how smoothly your app scrolls. This is kind of cool since scrolling smoothness feels right and is a sign of a good design.

Via iOS Dev Weekly.