This is what you can do with Enums in Swift

Channel Avatar
Comment
X
Share
This is what you can do with Enums in Swift
This is what you can do with Enums in Swift
Hello everyone, today we will talk about my favorite feature in Swift: Enums

Enums are art because they help you to represent a finite number of possibilities in our software problems. Swift makes use of enums in A LOT OF WAYS. Let’s begin and discover more about all its magic!

Content:
0:00 – Intro
0:27 – Blackjack Rules
0:54 – The problem that enums solve
2:01 – The basics
3:01 – Raw Values
4:30 – Enums support computer properties
5:09 – Avoid default in a Switch
6:09 – Blackjack Game
6:30 – CaseIterable
7:03 – Generate blackjack hands
7:23 – Associated Values
8:02 – Business logic for BlackJack
11:51 – Get associated values in a switch
12:31 – Protocols in Enums
13:16 – Recursive enums (Indirect)
15:00 – Getting a single case from an if
15:38 – BlackJack in SwiftUI
17:03 – Enum actions that represent UI events
18:58 – Do you want to learn more?

——

Source code shown in the video:
https://github.com/pitt500/swift-and-tips/tree/main/Enums

——
Resources:
* Swift.org: https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html
* Binary tree with enums: https://medium.com/@mrlauriegray/swift-3-enums-and-binary-search-trees-104f5e8d47e9

——
Other videos in the channel:
* Why can’t you use Int indices in a String?: https://youtu.be/k35T7E1hxeQ
* LazyVStack: https://youtu.be/yrly21IFQdY
* GeometryReader and apple Watch animations: https://youtu.be/ma4LP8RnyI0
* What’s new in SwiftUI 3.0: https://youtu.be/ewIeL1Trd5o
* Swift Concurrency: https://youtube.com/playlist?listPLHWvYoDHvsOUsGazZVW_ZdehusA0diIxs

—–
Don’t forget to subscribe to the channel, like it, and follow me on social media:

Twitter:
https://twitter.com/swiftandtips
https://twitter.com/pitt500

Finally, ask me for a video you would like to see next !

Credits:
– Music by Wataboi from https://pixabay.com/
– Video edited with LumaFusion

Take the opportunity to connect and share this video with your friends and family if you find it useful.

Keywords: swift and tips, swift && tips, swiftandtips, pitt500, Pitt, Pedro Rojas, Swift, ios, ios development, swiftlang, iosdev, Enum, associated value, raw value, rawValue, CaseIterable, Switch, case, case let, blackjack, SwiftUI, computer properties, CustomStringConvertible, indirect, recursive enums

Read Also

Leave a Reply

Your email address will not be published. Required fields are marked *