Samuel Défago's Corner

A cozy place for random babbling about iOS and tvOS development

Declarative Reactive Programming with Combine

13 December 2021

Any non-trivial application uses some form of data, whether retrieved from a web service, from a database or generated by user interaction. A well-behaved application properly responds to data changing over time while preserving a delightful uninterrupted user experience. Achieving this result can be a challenge, though, as most applications rely on several data sources whose changes might require a user interface update at any time.

Read More

Understanding SwiftUI Layout Behaviors

3 June 2021

The SwiftUI layout system is more predictable and easier to understand than UIKit layout system. But this does not mean how it works is entirely straightforward.

Read More

Building a Collection For SwiftUI (Part 3) - Fixes and Focus Management

15 September 2020

In part 2 of this article series we implemented a first working collection view in SwiftUI, powered by UICollectionView. This implementation is promising but still has a few issues and shortcomings that we will address in this final article.

Read More

Building a Collection For SwiftUI (Part 2) - SwiftUI Collection Implementation

14 September 2020

Faced with the inability to reach an acceptable level of performance with grid layouts made of simple SwiftUI building blocks, I decided to roll my own solution.

Read More

Building a Collection For SwiftUI (Part 1) - Mimicking Collections in SwiftUI

13 September 2020

SwiftUI does not offer any full-featured collection component like UIKit does, merely smaller building blocks like stacks, lists and scroll views (as well as lazy stacks and grids newly introduced in iOS and tvOS 14). In isolation none of these components is a true competitor to UICollectionView but, combined together, they can be used to build pretty advanced grid and table layouts.

Read More

Building a Collection For SwiftUI - Introduction

12 September 2020

UICollectionView has been an essential tool for Apple app developers since its introduction in iOS 6. Over the years it received a range of improvements and was ported to tvOS so that you can build layouts with the same formalism on both platforms. In iOS and tvOS 13 UICollectionView received the most significant enhancements ever made since its introduction, namely diffable data sources and compositional layouts.

Read More

Yet another article about method swizzling

4 December 2014

Many Objective-C developers disregard method swizzling, considering it a bad practice. I don’t like method swizzling, I love it. Of course it is risky and can hurt you like a bullet. Carefully done, though, it makes it possible to fill annoying gaps in system frameworks which would be impossible to fill otherwise. From simply providing a convenient way to track the parent popover controller of a view controller to implementing Cocoa-like bindings on iOS, method swizzling has always been an invaluable tool to me.

Read More

Sharing LLDB debugging helpers between projects using a dynamic library

11 March 2014

Xcode 5 added QuickLook support for standard types like UIImage, NSData or NSString, right within Xcode. Starting with Xcode 5.1, UIView and custom types can be quickly previewed as well, which can be quite convenient when debugging projects.

Read More