Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

AnyObject, Any, and any: When to use which?

AnyObject and Any got a new option any as introduced in SE-355, making it harder for us developers to know the differences. Each option has its use cases and pitfalls regarding when not to use them. Any and AnyObject are special types in Swift, used for type erasure, and don’t have a direct relationship with … 

 

How to use the #available attribute in Swift

Marking pieces of code as available or unavailable per platform or version is required in the ever-changing landscape of app development. When a new Swift version or platform version arrives, we’d like to adapt to it as soon as possible. Without throwing away support for older versions we can make use of the available attribute … 

 

@Published risks and usage explained with code examples

@Published is one of the property wrappers in SwiftUI that allows us to trigger a view redraw whenever changes occur. You can use the wrapper combined with the ObservableObject protocol, but you can also use it within regular classes. It’s essential to understand how the published property wrapper works since it can easily lead to … 

 

@StateObject vs. @ObservedObject: The differences explained

The @StateObject and @ObservedObject property wrappers tell a SwiftUI view to update in response to changes from an observed object. Both wrappers look similar but have an essential distinction to be aware of when building apps in SwiftUI. At first, you might wonder why you wouldn’t just always use @ObservedObject. I thought the same for … 

 

How to use the Redacted View Modifier in SwiftUI with useful extensions

The redacted view modifier in SwiftUI allows us to create a so-called skeleton view while our data is loading. Using a skeleton view instead of a spinner lets the user get a sense of how our views will look once the data is loaded. The user experience is smoother and gives the feeling of faster … 

 

@EnvironmentObject explained for sharing data between views in SwiftUI

@EnvironmentObject is part of the family of SwiftUI Property Wrappers that can make working with SwiftUI views a little easier. Sharing data between views can be challenging when working in SwiftUI, especially when we have a lot of child views being dependent on the same piece of data. We could solve dependency injection by inserting … 

 

Self-documenting code in Swift to increase readability

Self-documenting code helps explain a piece of code to other developers on a project without the need for actual documentation. The readability of our code is an essential part of making code easier to understand for developers that didn’t write the code. You could argue that it’s even crucial for yourself since you might visit … 

 

Tasks in Swift explained with code examples

Tasks in Swift are part of the concurrency framework introduced at WWDC 2021. A task allows us to create a concurrent environment from a non-concurrent method, calling methods using async/await. When working with tasks for the first time, you might recognize familiarities between dispatch queues and tasks. Both allow dispatching work on a different thread … 

 

Guard statements in Swift explained with code examples

Guard statements in Swift allow us to implement checks into our code that prevents the current scope from continuing. When writing code, we often have certain required conditions before continuing a method. An example can be unwrapping an optional input field before submitting a form. Required conditions can be either a boolean value that needs … 

 

Writing Swift Articles: Tips to become a better writer

Writing Swift articles is a great way to become a better engineer and is often seen as a required skill for Senior developers. By writing down your knowledge or learnings around a topic, you’re creating your knowledge base, which you can revisit whenever you want. At the same time, you’re contributing to the community by …