Swift Enum - Basics, Raw Values, Associated Values, CaseIterable & More

  Переглядів 47,939

Sean Allen

Sean Allen

4 роки тому

Check out more information on Devmountain:
bit.ly/35Tzs9K
In this video we discuss enums (enumerations) in Swift. I explain what enums are, how to use them as constants, Raw Value, CaseIterable, and Associated Values.
This tutorial was done using Swift 5.2 and Xcode 11.4.
Swift Documentation about Enums:
docs.swift.org/swift-book/Lan...
If you like my teaching style, I've released my first iOS dev course which is all about the take-home project job interview for iOS developers.
Course Info - seanallen.teachable.com/
Link to my book - How I Became an iOS Developer:
gumroad.com/l/sean-allen-origin
Hired.com:
hired.com/x/1n01g
Check out my podcast, iOS Dev Discussions:
itunes.apple.com/us/podcast/i...
Book and learning recommendations that help out the channel if you decide to purchase (Affiliate Links):
Ray Wenderlich Books:
store.raywenderlich.com/a/208...
Ray Wenderlich Videos:
store.raywenderlich.com/a/208...
Mark Moeykens SwiftUI Views & Animations Mastery:
www.bigmountainstudio.com/a/f...
Donny Wals - Combine Framework:
gumroad.com/a/909014131
Paul Hudson's Hacking With Swift:
gumroad.com/a/762098803
Learn Advanced Swift Here:
gumroad.com/a/656585843
Links to my iOS Dev Setup & iOS Dev Book Recommendations
www.amazon.com/shop/seanallen
Personal Links:
Twitter:
/ seanallen_dev
Instagram:
@seanallen_dev
#swift #softwaredeveloper #iosdeveloper

КОМЕНТАРІ: 121
@seanallen
@seanallen 4 роки тому
Watch Next - iOS Dev Launchpad - Beginner Swift Overview - ukposts.info/have/v-deo/qJ-CjnqNgoWLsHk.html
@misran449
@misran449 4 роки тому
i'm just going to pre-like every video from you that i open because at this point i know i will like them
@seanallen
@seanallen 4 роки тому
haha, thanks for the support!
@tajfun6955
@tajfun6955 4 роки тому
I`m working with swift from 2 years and every day i am finding a small piece of knowledge in videos or article on a medium where i surprised how many smart solutions is in Swift :D.
@mathiasriissorensen6994
@mathiasriissorensen6994 4 роки тому
Whenever I find myself stuck I turn to Sean Allen's videos first. Thanks again!
@F.Razor718
@F.Razor718 2 роки тому
I’m a complete beginner and your teaching style is so easy to follow. Thanks for sharing!!!
@Wheelhouse406
@Wheelhouse406 Рік тому
"Lets say 100,000 followers, we'll get there some day." He got there... I appreciate this guy helping me!!
@seanallen
@seanallen Рік тому
Happy to help, Jimmy! And yup, we got there eventually 😀
@steknika
@steknika Рік тому
when you say “you’ll get there” on the 100k, but currently it is a 103k is priceless! keep up the good work!
@david_lev
@david_lev 9 місяців тому
~ "We'll get there someday" 15:23 I think you got there in a big way.. Thanks for the great videos!
@seanallen
@seanallen 9 місяців тому
We did. It took a while but we got there. Glad you enjoy the content!
@KanyantaMubanga
@KanyantaMubanga 2 роки тому
You said:100k subscribers, we'll get there some day. 97.1k right now. That day's getting closer and closer Sean. Rooting for you!
@harungunes3735
@harungunes3735 3 роки тому
It's a deep dive with a simple explanation. Thank you, Sean!
@naforever1
@naforever1 3 роки тому
that moment when you wrote "100000" for UKposts subscribers number and said "we'll get there someday", I stoped the video to subscribe! lol .. great content and teaching style. learned a lot, thank you.. all the best
@seanallen
@seanallen 3 роки тому
Haha, thanks for the support, Ali. I appreciate it!
@zzhao463
@zzhao463 3 роки тому
Even better than the Stanford open class. (well for the parts covered. )
@leonidstechlearning2451
@leonidstechlearning2451 4 роки тому
I didn't know about the underscores to format numbers. Great! :3
@seanallen
@seanallen 4 роки тому
I like throwing in little tips like that in my videos.
@rdtba21qw
@rdtba21qw 4 роки тому
Sean mate, I’m nearly to the end of your course and have loved it. I had literally set aside the subject of your use of the SFSymbol enum for a point to brush up on when I’m done and you’ve just released this - perfect timing and as always super clear and concise - thank you!
@seanallen
@seanallen 4 роки тому
Glad you enjoyed it, Robin 😀
@eliastabaka
@eliastabaka 9 місяців тому
Great tutorial!
@ghargest66
@ghargest66 4 роки тому
Thanks for your service to the Swift community Sean. Another home run!
@seanallen
@seanallen 4 роки тому
Thanks for the kind words, Greg 😀
@thomasswatland
@thomasswatland 4 роки тому
So many times I've used a Struct with static properties to hold on to related constants, and it feels "off" every time. Naming a Struct with a plural just doesn't sit right. I never thought of just doing the same with enums! That just looks and feels so much better. Thanks Sean, keep up the good work!
@vinrbi8080
@vinrbi8080 2 роки тому
At 15:23 “100,000 subscribers. We’ll get there one day” Almost there! 98.3K right now! And just earned a new one from me. Keep up the good work!
@withd5943
@withd5943 Рік тому
One of the best tutorials on enum. Always coming back to refresh my knowledge here. 🙏
@seanallen
@seanallen Рік тому
Glad it's helpful each time!
@toxicraven9192
@toxicraven9192 4 роки тому
As always great clear and understandable videos, love your work
@seanallen
@seanallen 4 роки тому
Glad you like them!
@shynepo6
@shynepo6 2 роки тому
Sean: " 100k subs, we'll get there someday" ... Almost there man!! thanks for providing massive value to people on the IOS dev journey!
@keatsp
@keatsp 3 роки тому
Well you have one new sub now. Great video. Clear and concise. I am an experienced coder and still enjoyed the video.
@johndickson9709
@johndickson9709 Рік тому
Recent subscriber, your videos are excellent. Thanks for sharing your knowledge.
@Omeir34
@Omeir34 4 роки тому
Great tutorials Sean!
@sarahstice4095
@sarahstice4095 9 місяців тому
"100,000 subscribers... we'll get there some day." Sitting at 127k, love to see it. Love your videos, thank you.
@pritommazumder9897
@pritommazumder9897 3 роки тому
A pure community man!
@mrmillmill
@mrmillmill 2 роки тому
Incredible video and explanation of enum's Sean. It seems like enum's could be used all through out an app. Thank you sir.
@KimbrellBrad
@KimbrellBrad 2 роки тому
Less than 2 years later and you are at 99,400 subs! Feels like you were around 20K when I started subscribing. Congrats! Oh, and nice tutorial on enums! LOL
@bdaralan
@bdaralan 4 роки тому
Love enum especially when Swift allows associated value to have parameter name. For enum rawValue, I normally use it for database or cache value where the storage can only store primitive type and later I can recreate the enum using the rawValue.
@lycansre
@lycansre 4 роки тому
so much depth in your videos I like it you cleared almost everything about enums
@seanallen
@seanallen 4 роки тому
Happy to hear it was helpful, Meshall 😀
@natelehoux7604
@natelehoux7604 3 роки тому
Best intro to enums I've found anywhere!
@seanallen
@seanallen 3 роки тому
Thanks for the kind words, Nate!
@adarshraj312
@adarshraj312 Рік тому
new to swift. But, i know this guy... pretty Famous for iOS Dev 👏👏
@prachibile2798
@prachibile2798 2 роки тому
I really liked this video so much. As I am a new learner of iOS it was so useful.
@kuralaybiehler5638
@kuralaybiehler5638 10 місяців тому
Thank you! Clear and simple explanation of enum!
@seanallen
@seanallen 10 місяців тому
Glad you liked it!
@amitarya4894
@amitarya4894 7 місяців тому
Superb 💯, thanks for this
@seanallen
@seanallen 7 місяців тому
My pleasure 😊
@Faisal50x
@Faisal50x 3 роки тому
This is the best swift video ever seen. Damn Thanks Sean Allen for making this cool video.
@seanallen
@seanallen 3 роки тому
Glad you liked it!
@3909630
@3909630 4 роки тому
I usually insta-like every video from you, BUT YES IVE BEEN WAITING FOR THISSSSSSSSSS
@seanallen
@seanallen 4 роки тому
🙌
@jeffcournoyer5249
@jeffcournoyer5249 3 роки тому
I’ve been considering doing your GitHub followers class, but this video definitely did it for me! I just signed up and am excited to get started! Love your teaching style man!!!
@seanallen
@seanallen 3 роки тому
Thanks for the kind words, Jeff. Hope you enjoy the course!
@gakkieNL
@gakkieNL 4 роки тому
Nice video. Very educational and easy to follow! Thanks Sean!
@seanallen
@seanallen 4 роки тому
My pleasure!
@prachipatel2841
@prachipatel2841 3 роки тому
Great Example, I understand whole concept of ENUM and how it can be useful. Thank You so much! 😊
@seanallen
@seanallen 3 роки тому
Happy to help, Prachi!
@joshr9723
@joshr9723 4 роки тому
I love using Enums that have String rawValues because you can take a string and turn it into type SocialPlatform in this example. ie. let twitterCase = SocialPlatform(rawValue: "This is my favorite!"). This is great if you want to store a string value in your database, but then convert it back to an enum type to make it easier to pass around in your code.
@yuriisameliuk2118
@yuriisameliuk2118 4 роки тому
Good video . Thanks you Sean.
@nuwansameera9519
@nuwansameera9519 4 роки тому
Thanks you Sean!
@NadiyaLevytska
@NadiyaLevytska Рік тому
15:27 you said " we will get to 100k subs some day" and look at you now! great Channel! keep up amazing work
@seanallen
@seanallen Рік тому
Thanks Nad!
@mr.iguide7508
@mr.iguide7508 4 роки тому
This video was so needed. Thank you.
@andresuhartanto3385
@andresuhartanto3385 4 роки тому
Thank you so much for the clear explanation, i understand better about Enum thanks to you!
@seanallen
@seanallen 4 роки тому
Happy to help!
@JonatanEdOrtiz
@JonatanEdOrtiz 2 роки тому
Great video!
@ashokkumarmuthyam2986
@ashokkumarmuthyam2986 4 роки тому
Thank you sir. Your demonstration is awesome.I am from India.
@seanallen
@seanallen 4 роки тому
Happy to help!
@ketanchoyal7024
@ketanchoyal7024 3 роки тому
Awesome just what I was looking for, Thanks
@seanallen
@seanallen 3 роки тому
Glad I could help!
@RahulPahuja1991
@RahulPahuja1991 3 роки тому
Beautifully done thanks
@seanallen
@seanallen 3 роки тому
Happy to help!
@arslankhalid2919
@arslankhalid2919 4 роки тому
Hi, good to watch your video. please make a complete Deep video on computed and stored properties in swift. Thanks a lot
@guruitcompany
@guruitcompany 4 роки тому
Awesome! Thanks 👍
@lolerskates876
@lolerskates876 3 роки тому
I have used Enum for Arduino code. It makes it easier even for what color an LED should be
@gurvirsingh4332
@gurvirsingh4332 7 місяців тому
Haha Cheers to you, U have crossed 100000 subscribers 💥 as u mentioned someday you will reach.
@seanallen
@seanallen 7 місяців тому
🎉
@CraigSchubert
@CraigSchubert 4 роки тому
Great content yet again - thanks! :-)
@seanallen
@seanallen 4 роки тому
Glad you enjoyed it!
@armandmugabo1170
@armandmugabo1170 11 місяців тому
congratulations, you hit your once a youtube goal of 100k subs.
@seanallen
@seanallen 11 місяців тому
Thank you :)
@VeryBlueBot
@VeryBlueBot 4 роки тому
oh man this is so clear! thank you! Love these short gems really speeds up the learning process for a new language! Small question (which I probably could have just googled, but hey, Im typing already..) - Swift don't have 'default' in its switch statement?
@seanallen
@seanallen 4 роки тому
Yes, that was something I should have covered in the video. There is a default statement you can use as a "catch-all". In the example in the video, I wanted to show all the options to really illustrate the point. But yes, a simple default case will work as well.
@VeryBlueBot
@VeryBlueBot 4 роки тому
@@seanallen no worries its just a small thing :) just wanted to make sure its like in any other language..
@bitsurfer0101
@bitsurfer0101 3 роки тому
@@seanallen You answered my question and explained how to use enums at the same time. I don't feel like I have my head in the sand so much anymore.
@nileshjdarji
@nileshjdarji 4 роки тому
Awesome 👍
@mohdrahib1690
@mohdrahib1690 3 роки тому
Hi Sean, thanks for explaining Enum I have a question why an stored property can not be associated with enum ??
@tompov227
@tompov227 Рік тому
I find it super interesting how your keywords are set in Menlo but the rest of your editor is using SF Mono as the font. I know Xcode lets you but I have never seen people use different font faces for different source types
@mellamoraymond
@mellamoraymond 3 роки тому
Hi Sean. What's the difference of using enum vs struct when it comes to constant?
@brandonwinston
@brandonwinston 4 роки тому
thank you!
@seanallen
@seanallen 4 роки тому
Happy to help
@donathmm3881
@donathmm3881 4 роки тому
Good video! What is left is the default case!
@seanallen
@seanallen 4 роки тому
Hehe, it's hard to cover every possible thing 😀
@vickyphan5494
@vickyphan5494 3 роки тому
Thanks for a great video!! What bootcamp did you go to?
@seanallen
@seanallen 3 роки тому
Glad you liked it, Vicky! I went to one called Mobile Makers in San Francisco back in 2015. It actually no longer exists.
@Rahul-jf5kf
@Rahul-jf5kf 2 роки тому
suppose I have multiple fields for each enum case like title, description, image URL. and are static for each case now i want list of all titles, list of all descriptions so son and also one method to get url from title image from title . please explain
@erickramones2167
@erickramones2167 4 роки тому
any videos on when to use private or public properties?
@seanallen
@seanallen 4 роки тому
I created a video about access control here: ukposts.info/have/v-deo/inZ4ebCieZdplGg.html
@erickramones2167
@erickramones2167 4 роки тому
@@seanallen cool, thanks.
@nikandrmarhal
@nikandrmarhal 4 роки тому
You also haven’t mentioned the `if case let` syntax. Would be a great topic for another video
@seanallen
@seanallen 4 роки тому
Yup, it's a difficult balance to make a concise video, but also cover enough of the fundamentals. It's hard to cover every aspect of a topic in one video.
@T0m4sfn
@T0m4sfn 2 роки тому
Just here to say you are about 13k left to reach 100k subscribers as the last example follows.
@shadieossei4336
@shadieossei4336 2 роки тому
You're gonna get to 100,000 subscribers and be eligible for sponsorship
@Karma_Rinku
@Karma_Rinku 3 роки тому
You did not tell about recursive enum the last topic i waiting to see this but.. not there. bcoz i was confused in that . make on that a video
@rrakesh05
@rrakesh05 4 роки тому
Just awesome tutorial mate...
@seanallen
@seanallen 4 роки тому
Glad you liked it
@mrmillmill
@mrmillmill 2 роки тому
Anyone have any ideas for creating a function that adds cases to an enum?
@maliknrishabh
@maliknrishabh 4 роки тому
Another way to use enums could be computed vars
@douglasrutledge1325
@douglasrutledge1325 2 роки тому
i left more confused, i need more, how real data is pushed into an enum and then get the results, for example, if you explained 'func set' more then maybe I would of gotten it.
@douglasrutledge1325
@douglasrutledge1325 2 роки тому
what is 'ItemInfoType' ???
@farakhakimov
@farakhakimov 4 роки тому
I think we can use default state instead of using all other cases on the last example 🙂
@seanallen
@seanallen 4 роки тому
You are correct. That would work.
@maheshgvelly
@maheshgvelly 3 роки тому
Whats a recursive enum?
@cometmace
@cometmace 4 роки тому
1:18 An enum has to have cases 4:09 SFSymbols - no cases. Just static lets. Please to be explaining?
@saj5935
@saj5935 4 роки тому
static let also similar to case you should know static keyword mean
@gjermundification
@gjermundification 4 роки тому
Compiler protocols: `cat /opt/local/dev/swift/stdlib/public/core/CompilerProtocols.swift | grep "public protocol" | grep -v _ | sort` github.com/apple/swift/blob/master/stdlib/public/core/CompilerProtocols.swift
@paramsingh4104
@paramsingh4104 2 роки тому
Swift enums are really advanced, can put Typescript to shame.
@melendezjonas6404
@melendezjonas6404 3 роки тому
The jittery ash opportunely water because level additionly alert given a hollow dead. bloody, furry furtive cobweb
@MarkizBoneco
@MarkizBoneco 11 місяців тому
You've achieved 100k subscribers
Swift Access Control Explained
9:44
Sean Allen
Переглядів 32 тис.
ВИРУСНЫЕ ВИДЕО / Мусорка 😂
00:34
Светлый Voiceover
Переглядів 7 млн
How to use Lazy in Swift
9:56
Sean Allen
Переглядів 38 тис.
🔴 Enums in Swift| Intermediate & Advanced Fundamentals
29:11
AppStuff
Переглядів 1,2 тис.
Swift Structs - Value Type vs. Reference Type
7:54
Sean Allen
Переглядів 15 тис.
UIViewController - Lifecycle | Swift | viewDidLoad
7:57
Sean Allen
Переглядів 39 тис.
Why should you use enums and associated values? 🤔
6:55
Vincent Pradeilles
Переглядів 2,2 тис.
I Made 200 Python Projects...Here Are My 5 FAVORITES
11:23
Tech With Tim
Переглядів 102 тис.
iOS Concurrency and Threading - iOS Interview Question - Swift
7:50
Sean Allen
Переглядів 104 тис.
Swift Optionals - How to Unwrap (real examples)
14:20
Sean Allen
Переглядів 10 тис.
Swift For Beginners - Class & Inheritance Explained
15:42
Sean Allen
Переглядів 16 тис.
План хакера 🤯 #shorts #фильмы
0:59
BruuHub
Переглядів 951 тис.
Распаковка айфона в воде😱 #shorts
0:25
НЭКС
Переглядів 820 тис.
Интел подвинься, ARM уже в ПК!
14:06
PRO Hi-Tech
Переглядів 137 тис.
Как открыть дверь в Jaecoo J8? Удобно?🤔😊
0:27
Суворкин Сергей
Переглядів 765 тис.
#smartphone #screenprotection #tech #shorts #magicjohn
1:01
MagicJohn
Переглядів 6 млн