Understanding Swift closures and pros/cons over protocols & delegates | iOS Dev Live Mentoring

preview_player
Показать описание
Learn how to fully grasp closures in Swift, how and when to replace Swift protocols with closures, tuples, structs, or classes. And pros/cons of using delegates vs. closures for async operations.

Like and share this content with someone that you believe will benefit from it. See you in the next episode.

---

How to Build iOS Apps with Swift, TDD & Clean Architecture series↴

Caio & Mike's Book Suggestions ↴

---

Subscribe to our channel ↴

You can also find us on ↴

Caio ↴

Mike ↴

Join the iOS Lead Essentials program ↴

Visit our website ↴
Рекомендации по теме
Комментарии
Автор

Thanks for sharing these mentoring sessions. I think as a beginner, it can be quite difficult to see which entity or class is implementing the closure, and which class is just declaring it.

I struggled with the concept of closure myself for quite a while to be honest, especially when I was navigating through a large codebase that heavily uses closures at work. It did really hurt my brain for quite sometime.

MainActor
Автор

This reminds me of strategy pattern a lot :P
Also promises are a great way for dealing with async

konstantinosnikoloutsos
Автор

Thanks for sharing and Paulo for asking this one.

JJ-upxt
Автор

This is a prety common pattern in other languages too. The Kotlin documentation, for example, says "an interface with only one abstract method is called a functional interface, or a Single Abstract Method (SAM) interface", with some sintatic sugar for SAM conversion by the Kotlin compiler.

kafran
Автор

The way you guys explain this is amazing! Thank you for many existential questions.

yenniferhurtado
Автор

Could you please give an example of how to handle strong reference cycle in the case of closure callbacks

rijosamuel
Автор

what tool u used to design that block diagram?

GaneshKumar-ehfj
Автор

thanks for explaining it in such a simple way.

and you are mentioning some lecture in video? i would love to learn new stuff

tanvirsingh
Автор

In my opinion, greatest closures cons is no params names

f.artemenkov