The @Environment property wrapper in SwiftUI allows you to read values from a view’s environment. You’re able to configure an environment value yourself or make use of the default available values. Please read my article on Property Wrappers before diving into this one. Note that this is a different wrapper than @EnvironmentObject, which I explain …
Bar Chart creation using Swift Charts
Apple introduced Swift Charts during WWDC ’22, allowing you to visualize data into bar charts. Before this framework, we had to include all kinds of third-party solutions to draw charts in SwiftUI. Visualizing data using a similar declarative syntax to SwiftUI is simply fantastic. A bar chart is just one of the available options to …
Statistical significance and its importance with app experiments
Statistical significance tells you whether the result from an experiment is likely attributable to the specific change you did. It’s an essential quantification when running app experiments, and it prevents you from concluding too early about a change you’ve made. I’ve been running hundreds of experiments throughout my career and only a few of the …
Identifiable protocol in SwiftUI explained with code examples
The Identifiable protocol in SwiftUI allows you to add a unique object identity. The protocol requires a single ID property of any hashable type, making it a flexible protocol for all kinds of instances. While it’s a relatively simple protocol, a few possible edge cases can cause unexpected bugs in your SwiftUI code. Therefore, it’s …
Key press events detection in SwiftUI
Key press events detection in SwiftUI allows you to respond to a keyboard key like return (enter), shift, command, and more. While mostly Mac apps use keyboard events, you must consider adding support for iPad apps since external keyboards can be used. SwiftUI offers several modifiers to listen to key press events, making it effortless …
The power of consistency in side projects
The success of your side projects can be mixed, but consistency brings power to your results. It’s often easier to start a new project when results are disappointing rather than sticking to that high-potential project you’ve always believed in. I’ve been developing a few side projects over the years but managed to stay away from …
Test-Driven Development (TDD) for bug fixes in Swift
Test-driven development (TDD) is a technique that requires you first to write a failing test before you start implementing a solution. While it’s a technique developers use during general development, there’s a way to apply it only for bug fixes. Finding out about a bug can already be disappointing, but finding out about a bug …
Optionals in Swift explained: 5 things you should know
Optionals are in the core of Swift and have existed since the first version of Swift. An optional value allows us to write clean code while at the same time taking care of possible nil values. If you’re new to Swift, you should get used to the syntax of adding a question mark to properties. …
Third-party libraries acknowledgments using a Settings bundle
Third-party libraries help developers build apps faster but often come with a license. The MIT license is likely the most common, but there are many others that, together, require you to acknowledge the usage of the library in return for getting free access. I’m not going to dive deep into the details of each license …
Extensions in Swift: How and when to use them
Extensions in Swift allow you to extend an existing class, struct, enumeration, or protocol with new functionality. Whether it’s a custom type defined by you or a current type inside of a framework, extensions can create custom accessors and enhance the types you work with. So-called retroactive modeling allows you to extend types for which …