0:00 / 0:00
#swift#protocols#associatedtype
Generics in Swift: Protocols with associated types
Swift and Tips
13K subscribers • 12 videos on Hallway
- Recommended by 1 person: 1 in engineering communities.
- Linked in the descriptionpitt500/swift-and-tips
Intermediate. Assumes working knowledge.
11K views5 years ago1 recommendation
Programming languagesMobile developmentSwiftiOS and SwiftUI
How to create and use protocols with associated types in Swift and solve common compiler errors.
Hello guys, welcome to another video! Today we will continue with the Generics series talking about protocols with associated types. SwiftUI views were made with these special protocols, How can we create our own associated types? Can I create a generic protocol with square brackets? How does Swift infer associated types?... we will solve all those questions and also see how to use protocols when we found the error "Protocol can only be used as a generic constraint...". Before continue I recommend you to watch the first episode: Part 1: youtu.be/W947iXBIFu4 Content: - Intro - Associated types in SwiftUI - What are associated types? - Generic type with a protocol with associated type - Extending from a protocol with associated type - How to solve "Protocol can only be used as a generic constraint ..."? - Outro ------ References: - docs.swift.org/swift-book/LanguageGuide/Generics.html - developer.apple.com/videos/play/wwdc2018/406 - swiftbysundell.com/basics/generics/ Source code showed in this video: github.com/pitt500/swift-and-tips/blob/main/Generics/Associa… ------ Other videos in the channel: - Protocols in Swift: youtube.com/playlist?list=PLHWvYoDHvsOX_H712wbhzSW0xqHsFy2j9 - UIKit in SwiftUI: youtube.com/playlist?list=PLHWvYoDHvsOX8vB95YIkv_r5e5IXWcyu2 - Struct vs Classes: youtu.be/zOeC7pxOIhk ----- Don't forget to subscribe to the channel, like it, and follow me on social media: Twitter: twitter.com/swiftandtips twitter.com/pitt500 Finally, ask me for a video you would like to see next 😄! Credits: - Music by Wataboi from pixabay.com/ - Video edited with LumaFusionWhy it's here
1 person recommends thisWhat people say. Recommended as a helpful guide to understanding associated types in Swift protocols.