3 min read

Issue #69

Hi there, welcome to the 69th issue of iOS Code Review. Let's dive into this issue's insights and discoveries together ✨

Step into the future of Apple tech at Pragma Conference 2024, happening October 29-30 in Bologna, Italy! Get ready for a full day of deep-dive workshops followed by two days jam-packed with sessions and awesome networking. This is THE event for Apple developers — you won't want to miss it!
Secure your spot!

Goodbye GeometryReader, hello containerRelativeFrame

From iOS 17 we can use containerRelativeFrame(_:alignment:) for giving views size calculated from the size of its parent. containerRelativeFrame(_:count:span:spacing:alignment:) is to be used when multiple views will be visible in the container.

Refer to official documentation for in-depth explanation, or to a video by Flo for a quick overview:

containerRelativeFrame(_:alignment:) | Apple Developer Documentation
Positions this view within an invisible frame with a size relative to the nearest container.
containerRelativeFrame(_:count:span:spacing:alignment:) | Apple Developer Documentation
Positions this view within an invisible frame with a size relative to the nearest container.

New Content Margins modifier

Another handy iOS 17 addition in SwiftUI is a view modifier called contentMargins . It allows to inset the content of some of the system views, without getting additional side effects that come from adjusting the safe area:

Content margins in SwiftUI
SwiftUI introduced a set of view modifiers, allowing us to manage the safe area in our views efficiently. In many cases, the safe area is where you want to put your content. Today, we will learn about the new content margin concept that SwiftUI introduced and how it differs from the safe area.

Computed property or a function

func name() -> String or var name: String , func nearestNeighbour() -> String or var nearestNeighbour: String ? There are conventions in Swift that will help you decide:

Deciding between a computed property and a function in Swift – Donny Wals
In Swift, we can use computed properties to derive a value from other values defined on the same object. Being able to do this is super convenient because it means that we don’t have to manually make…

Overrated Swift features

In this article you'll read about a few Swift features that seem cool but do more harm than good when overused: implicit initialisers with .init, subscripts, and more:

The cool Swift features that you should not (ab)use
As an iOS developer, I used to work on a lot of legacy code, or I tried some Swift features myself. After using them or seeing some of them…

✌️
Alright, that's it for today! Let's spread the good code vibes ✨🧘🌈☀️
Thank you to Pragma Conference for sponsoring this issue ❤️