Empty Strings in Swift

How do you tell if a string is empty in Swift? That depends on what you mean by “empty”. You might mean a string with zero length, or maybe also an optional string that is nil. What about a “blank” string that only contains whitespace. Let’s see how to test for each of those conditions with Swift.

Read On →

Comparing Version Strings

How do you compare two version strings in Swift? For example, how can I check if version “2.2.5” is higher than “2.0.3” or that a version is at least “1.8.5”? As long as your version strings follow a consistent format it turns out to be not too hard.

Read On →

Using The Responder Chain

The delegate pattern is often used by a child view controller to communicate with its parent view controller, but it’s not the only way. A lesser used, but occasionally useful, alternate approach is the responder chain.

Read On →

Swift 5 Frozen enums

Are you upgrading an Xcode project to Swift 5? It’s a mostly pain-free experience, but you might hit a warning about switching on enums with additional unknown values.

Read On →

State Restoration With Swift Structs

How do you implement state preservation and restoration when your view controller model is a Swift struct that does not support NSCoding? My notes on how to wrap the struct in a dictionary with some help from Sourcery.

Read On →
Archives Categories

No time to watch WWDC videos?

Sign up to get my iOS posts and news direct to your inbox and also get my free iOS Size Classes Cheat Sheet

Unsubscribe at any time. See Privacy Policy.