Select Page
The Danger of String Literals and Stringly Typed Code

The Danger of String Literals and Stringly Typed Code

Object literals are very useful and they often make your code easier to read and understand. String literals are a bit different, though. It’s true that a string literal is the easiest solution to create a String instance. It’s straightforward and everyone understands what’s going on. But there’s a price you pay every time you use a string literal. Did you know that?

Dequeueing Reusable Views With Generics and Protocols

Dequeueing Reusable Views With Generics and Protocols

In today’s tutorial, I’d like to show you an elegant example of the power and versatility of generics and protocols. I stumbled upon this implementation while browsing the RxDataSources repository a few months ago. I learned the technique I outline in this tutorial from Segii Shulga. Let me show you what it looks like.

Exclamation Marks and Fatal Errors

Exclamation Marks and Fatal Errors

Fatal errors have a negative connotation and with reason. You should use them sparingly if you want to avoid having your application crash and burn at the slightest hiccup. Despite their negative undertone, fatal errors are an integral part of my workflow as I write elsewhere in this book.

Unboxing JSON With Swift and Unbox

Unboxing JSON With Swift and Unbox

Many developers new to Swift seem to be struggling with JSON. Despite the speed of Foundation’s JSONSerialization class, it hands you an object of type Any, leaving it up to you to unwrap the object you received.

Four Clever Uses of Swift Extensions

Four Clever Uses of Swift Extensions

If you’re reading this, then I assume you’re familiar with Swift extensions. A Swift extension allows you to add functionality to a type, that is, a class, a structure, an enumeration, or a protocol. But extensions are more powerful than that. In this tutorial, I’d like to show you four clever uses of Swift extensions.

What Is the Difference Between Strong, Weak, and Unowned References

What Is the Difference Between Strong, Weak, and Unowned References

In yesterday’s installment of Understanding Swift Memory Management, you learned how weak and unowned references can be used to break a strong reference cycle. It’s time to take a closer look at what sets weak and unowned references apart from strong references. We also revisit weak and unowned references. What is the difference between weak and unowned references? When is it appropriate to choose an unowned reference over a weak reference?