Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

Have you ever created a SwiftUI binding using the Binding(get:set:) initializer? If so, you may want to reconsider. To understand why, check out our newest episode clip where we show how this initializer makes it difficult for SwiftUI to track where the binding came from.

21,720 görüntüleme • 1 yıl önce •via X (Twitter)

9 Yorum

Point-Free profil fotoğrafı
Point-Free1 yıl önce

For a high-quality version of this clip:

glueckkanja profil fotoğrafı
glueckkanja4 yıl önce

Are you searching for a simple way to deploy device certificates with #Intune? Check out SCEPman at

George Elsham profil fotoğrafı
George Elsham1 yıl önce

Really interesting, thank you! Never thought about this but it makes sense. This is another reason why SwiftUI should be open source—to make debugging issues like this easier.

Petr Šíma profil fotoğrafı
Petr Šíma1 yıl önce

This is great info! I never knew Binding(get:set:) is forbidden fruit, I'll need to reevaluate a lot of what Im doing. But... Won't you get further trouble if flag changes? Screenshot should be self-explanatory, lmk what you think.

Point-Free profil fotoğrafı
Point-Free1 yıl önce

Sorry, I'm not sure what you are demonstrating with the screenshot. The logs printed shouldn't be surprising. The first equality should be false because the data used to derive the key path has changed. And the second equality should be true because it's the exact same key path.

S profil fotoğrafı
S1 yıl önce

when do you recommend using subscript over a func?

Point-Free profil fotoğrafı
Point-Free1 yıl önce

If you need a key path, which is the case for deriving bindings, then you must use a subscript because only subscripts get key paths. Methods do not.

phil | 🇨🇭 👨🏼‍💻📱 | 🏳️‍🌈 profil fotoğrafı
phil | 🇨🇭 👨🏼‍💻📱 | 🏳️‍🌈1 yıl önce

Does this also apply to Bindings created with that initializer that, for example, are computed var‘s on the View or some Observable object? Or only to those „ad-hoc“ ones inside a view body?

Point-Free profil fotoğrafı
Point-Free1 yıl önce

Yes, ideally you wouldn't use that initializer if possible. You may not be running into any of the possible problems right now, but there's always the chance in the future things could get a little whacky.

Benzer Videolar