Select Page
What Is a Singleton and How To Create One In Swift

What Is a Singleton and How To Create One In Swift

The singleton pattern is a widely used design pattern in software development. Despite its popularity, it’s often considered an anti-pattern. Why is that? In this tutorial, I explain what the singleton pattern entails and how to create singletons in Swift.

Are Singletons Bad

Are Singletons Bad

When I first started dabbling with Cocoa development, I almost immediately came into contact with the singleton pattern. Many Cocoa frameworks, including UIKit and Foundation, use the singleton pattern.

References, Delegation, and Notifications

References, Delegation, and Notifications

A typical Swift application is composed of dozens and dozens of objects, working together to make your application tick. To get the job done, these objects need the ability to talk to each other. In this tutorial, we take a look at three common patterns that enable objects to communicate with one another. We also discuss when to use which pattern and, more importantly, when to avoid a particular pattern.

Embracing Optionals in Swift

Type safety is a fundamental concept of the Swift programming language and optionals neatly tie into Swift’s strict type safety rules. The concept underlying optionals is simple, an optional has a value or it does not.

Elegant Controls in Swift With Closures

In yesterday’s tutorial, I showed you how to use closures as an alternative to delegate protocols. Closures—or blocks in Objective-C—are incredibly useful and I frequently use them as an alternative to existing design patterns. One such pattern is the target-action pattern.

Five Signs of Code Smell in Swift

Pixelsync was the first iOS application I published on the App Store. For a first project, it was quite complex and far more challenging than I had anticipated. The project grew quickly as I added more features and maintainability quickly became an issue I could not ignore.

More Swift and Model-View-ViewModel in Practice

More Swift and Model-View-ViewModel in Practice

In the previous tutorial, we laid the foundation for adopting the Model-View-ViewModel pattern in the profile view controller of Samsara. We already implemented the Time section of the table view. This tutorial continues with the Warm Up and Cool Down sections.