Opaque Types in Swift Explained (2023) - iOS

  Рет қаралды 10,046

iOS Academy

iOS Academy

Күн бұрын

Пікірлер: 26
@iOSAcademy
@iOSAcademy Жыл бұрын
Follow for more linkedin.com/in/afrazsiddiqui
@lindsaymcrory4215
@lindsaymcrory4215 Жыл бұрын
Nice! I like the clear explanations and focus on a specific topic in digestible time.
@iOSAcademy
@iOSAcademy Жыл бұрын
Glad it was helpful!
@milindntrivedi
@milindntrivedi Жыл бұрын
Thank you for the simple explanation much appreciated. Was banging head across room cause of it, read many times couldn't understand the practical use
@iOSAcademy
@iOSAcademy Жыл бұрын
Glad it helped!
@attaliabrown6164
@attaliabrown6164 7 ай бұрын
This helped alot! Thanks!
@iOSAcademy
@iOSAcademy 7 ай бұрын
Glad it helped!
@arseniikovalenko899
@arseniikovalenko899 Жыл бұрын
I have read somewhere that in future swift versions there will be compiler warning when you are using protocol types (ex. in method params, inits, etc.) you should specify keyword any. This warning is a result of dispatch types and it helps helps the developer understand performance degradation. So we can use generics while using protocols. Example: protocol MyProtocol {} 1. func doSomething(message: MyProtocol) {} 2. func doSomething(message: T) where T: MyProtocol {} 3. func doSomething(message: some MyProtocol) {} This looks like the same, but it isn't. 2nd and 3rd do the same thing using static dispatch, unlike 1st, that uses dynamic dispatch. So, the question is, if I'm correct, do you know about it and should we use some keyword to all protocol types even without associated types?
@iOSAcademy
@iOSAcademy Жыл бұрын
Yes indeed
@rahuljamba5846
@rahuljamba5846 Жыл бұрын
Great !! thanks for sharing.
@iOSAcademy
@iOSAcademy Жыл бұрын
Youre welcome
@byaruhaf
@byaruhaf Жыл бұрын
Thanks for this video, can you make a video on the problem with using any rather than some
@iOSAcademy
@iOSAcademy Жыл бұрын
Sure thing!
@nobodynotcoolbutnice7032
@nobodynotcoolbutnice7032 Жыл бұрын
谢谢,这是一个非常有用的视频。
@iOSAcademy
@iOSAcademy Жыл бұрын
Youre welcome
@kangdeveloper82
@kangdeveloper82 Жыл бұрын
appreciate 🎉
@iOSAcademy
@iOSAcademy Жыл бұрын
Thanks
@spixels6880
@spixels6880 11 ай бұрын
Comparing to Rust, seems like "some" is "impl", and "any" is "dyn"
@olegkaliuzhnyi8722
@olegkaliuzhnyi8722 Жыл бұрын
Thank you for the video! The docs say all of the possible return values must have the same type. However I saw a SwiftUI example which returns different types and that gets compiled successfully. struct Navigation: View where Content: View { @ViewBuilder var content: () -> Content var body: some View { if #available(iOS 16, *) { return NavigationStack(root: content) } else { return NavigationView(content: content) } } } Could you explain why that works or point me out to some resources with a good explanation? It's been a week trying to understand it...
@olegkaliuzhnyi8722
@olegkaliuzhnyi8722 Жыл бұрын
Oh I guess I’ve found where to dig next. It seems to be the ViewBuilder which does this magic trick
@shurale85
@shurale85 Жыл бұрын
So the main idea of some is making type erasing easier, isn’t it? But not using diff types in typealias since it will likely brake the execution
@iOSAcademy
@iOSAcademy Жыл бұрын
Yes
@victorriurean
@victorriurean Жыл бұрын
nice
@iOSAcademy
@iOSAcademy Жыл бұрын
Thanks
@Siberian-Vladik
@Siberian-Vladik Жыл бұрын
there are saint people. you're definitely one of them
@iOSAcademy
@iOSAcademy Жыл бұрын
Ha thanks
Type Erasure In Swift | iOS Development
15:19
iOS Academy
Рет қаралды 8 М.
Colorful Pasta Painting for Fun Times! 🍝 🎨
00:29
La La Learn
Рет қаралды 308 МЛН
Swift: Actors Introduction (2023, Xcode 13) - iOS
8:54
iOS Academy
Рет қаралды 39 М.
Better Swift Closures Explained - Swift Tips (2023) - iOS
6:02
iOS Academy
Рет қаралды 7 М.
Indirect Enums in Swift - iOS Tutorial (2023)
9:37
iOS Academy
Рет қаралды 7 М.
How to use opaque return types - Swift for Complete Beginners
13:42
Opaque types: Masking your concrete types
22:18
Swift and Tips
Рет қаралды 4,6 М.
Intro to Sendable in Swift 5 (2022)
11:23
iOS Academy
Рет қаралды 12 М.
The Vim Experience
45:19
Bog
Рет қаралды 121 М.
Swift Tips #31 - some (Opaque Return Types)
8:02
Vincent Pradeilles
Рет қаралды 5 М.