This is better than my university lectures, thank you!!
@seanallen10 ай бұрын
Thanks for the kind words :)
@mario_luis_dev Жыл бұрын
you’re really crushing it with these videos Sean. Not only the clear way you teach things, but also the high quality of the videos with all the animations / transitions and such. Masterful 👏
@nX-2 жыл бұрын
Good simple explanation! Just one small detail (but it is just nit picking), is that at 3:40, the struct is not instantly copied once you assign it to a new variable. It is only copied once you mutate the new variable, since structs in Swift use CoW (Copy-on-Write) semantics.
@Stricken1742 жыл бұрын
yep, but no one cares :D
@nX-2 жыл бұрын
@@Stricken174 This is actually asked in some interviews ;) Also, it can be important to know when dealing with performance issues. But ofc if you are just learning these concepts as a beginner, it is not important at all.
@seanallen2 жыл бұрын
Agreed. These videos are meant for those studying for their first Jr dev job. You’re not gonna fail a Jr dev interview if you don’t explain CoW semantics. There’s a balance in teaching of not going too deep into the weeds that you overwhelm the learner.
@Stricken1742 жыл бұрын
@@nX- Thats true, but some of interviewers have no idea about cow) Good to know it for yourself.
@xpopcornx17472 жыл бұрын
The bigger error is that he claims structs are objects.
@chevlim8 ай бұрын
You explained this so well! Was learning about this in Swiftful Thinking’s video playlist but had trouble understand. Your analogy is a gem!
@seanallen8 ай бұрын
Glad it was helpful!
@dmitryarkharov25252 жыл бұрын
As a practicing IOS developer I’m aware of class / struct differences, yet your explanation is the best I’ve ever encountered 🎉🎉🎉
@giantdworf2026 Жыл бұрын
you know I have learned today! not everyone is meant to be a teacher seriously, same topic same code different explanation. With these guy I understood the difference in less than 5min you're the best
@ndrukz Жыл бұрын
this explanation was the best sean. Thank you very much
@seanallen Жыл бұрын
You're very welcome!
@nmyster7 ай бұрын
Great video! From a simple point of view in swift is “safe” to assume you can use struct by default unless you need class specific features. Structs seem like class-lite
@kambala1199 Жыл бұрын
Also classes have initializers/deinitializers due allocation on the heap
@Ikona7312 жыл бұрын
52sec too late notification. Great content, I enjoy the way you teach.
@paulcristo11 ай бұрын
Very informative. Thanks.
@PrestonWeight2 жыл бұрын
Great stuff!
@seanallen2 жыл бұрын
Glad you enjoyed it, Preston!
@borysg9999 Жыл бұрын
Thank You mate ! really helpful video
@seanallen Жыл бұрын
Glad it helped
@borysg9999 Жыл бұрын
Good series on the way to Junior IOS dev and to sum up before interviews
@seanallen Жыл бұрын
Best of luck on the interviews!
@asherazeem32822 жыл бұрын
Google sheet example was nice
@Corazon15 Жыл бұрын
Could you please add “Closures” to your Swift course? I’m currently doing your SwiftUI course and I’m having a wonderful time! You explain the material better than my Lecturers at University. Thank you
@seanallen Жыл бұрын
Glad you’re enjoying them! I did a recent video about closures here - Swift Closures Explained kzbin.info/www/bejne/hHWXZamHas59r8U
@fatihsahin6863 Жыл бұрын
beautfiul explanation liked and subscribed
@seanallen Жыл бұрын
Glad you liked it!
@AmitBiswastunebox Жыл бұрын
Hi Sean can you please make a tutorial on “ State Machine Design in Swift” ? Please please
@ingongoyama3995 Жыл бұрын
A reference type lets the calling code store the input value remotely in the class. Value type is a struct that lets the calling code block store the input value locally inside itself.
@MachineLearning-rw7jd Жыл бұрын
Your analogy would be great if you had mentioned that you were not using Excel with cloud features. Since you have not, you made it look like Excel is stuck in time.
@nickdhrones6425 Жыл бұрын
New to Swift, but 50 years coding experience. Did you mean to say that a Class Instance is by-ref rather than a Class?
@Dfso200x10 ай бұрын
yes
@tcurdt2 жыл бұрын
The most interesting bit you unfortunately didn't cover. What happens if the properties of a struct are not primitive types? How does that influence the reference vs value situation? That's where it gets a little more tricky to reason about. Otherwise a nice explanation.
@nileshjdarji2 жыл бұрын
Another great video with analogy. One question I have though, does it matter, when creating a struct, the properties are declared as ‘let’ or ‘var’. I am sure there is a difference but what is it is hard for me to picture. Any hint you can point to?
@redcrafterlppa3032 жыл бұрын
Exclamer I'm not a swift developer I just threw up the wiki and used my knowledge of other languages. If you have a struct: struct Point { var x: int let y: int } And an "instance" : var p = Point(x: 0, y: 0) p.x = 5 //works p.x is now 5 p.y = 4 //error p.y is immutable If you declared p with let: let p2 = Point(x: 0, y: 0) p.x = 5 //error p is immutable p.y = 4 //error p is immutable In short the higher level var/let decides for all underlying fields. Imagine it like a tree where every let is a dead end and var is another emerging branch. Hope this helps and is somewhat correct.
@tszkinwong6170 Жыл бұрын
clear explanations!!!
@kadeus Жыл бұрын
Great explain
@radfaredu6442 жыл бұрын
Tank you !
@umerakram26459 ай бұрын
why do we use struck instead of class can you elaborate it further
@mussadiqhafeez932311 ай бұрын
very helpful
@seanallen10 ай бұрын
Glad it helped
@chrispy104k2 жыл бұрын
Your explanations are spot on Sean.
@seanallen2 жыл бұрын
I appreciate it, Chrispy!
@VladimirKim-cl3rh Жыл бұрын
Bro Struct in Swift not a "pure value type", if you don't know - it's a "value semantic type", and proceed using the struct sometimes you may get unusual behavior related storage in heap or stack memory allocation
@Relllz521 Жыл бұрын
Bro you explain things in a way that I actually understand. I’m learning this from scratch with no coding experience, so trying to learn the why behind why things are coded a certain way and the functions has been a challenge.
@jeanchindeko5477 Жыл бұрын
Struct is to create Type which is not same as Class which create Object
@Scott-yq5sx Жыл бұрын
Thanks!
@CodingWithTaaxo Жыл бұрын
What about actor
@stesch-f Жыл бұрын
I'm still astounded that arrays and dictionaries are structs.
@tapiokuusisto47802 жыл бұрын
How do structs behave as part of swiftui observable objects? I bumped into some weird behaviors when relying on observable objects having nested structures in them. Textfields with bindings & cursor jumping to very end of text when editing in the middle of a field namely. Another video on this maybe? Thanks for well made videos - I’ve learned quite a bit from them!
@gjermundification2 жыл бұрын
There are some issues / features when it comes to when views are redrawn, it gives greater control when done right.
@swiftui_and_swift Жыл бұрын
super helpfull
@fragment72 жыл бұрын
so struct is just like a structure. like a school who have their preset ( lessons teachers infrastructure) unchange, while class is the class itself, moving towards grade, to the next, inheriting previous knowledge acquired
@ebubeawachie2 жыл бұрын
Congratulations on making a simple topic more complex with this explanation 😂. But then if it somehow works for you, more power to ya.
@ebubeawachie2 жыл бұрын
Your analogy nested classes inside structs. Making a class a property or feature of a struct.
@Daystarjn2 жыл бұрын
Bro please I just purchased your SwiftUI Mega Bundle. But can you please recommend me a Mac machine to buy for the course please
@bobweiram63212 жыл бұрын
What's your budget? Right now you can buy a Mac M2 mini for about $500. This is the best deal going if you're OK with being chained to a desk. If you want something portable, an M1 or M2 MacBook Air is a fantastic buy. Alternatively, you can buy a used M1 MacBook Pro.
@Daystarjn2 жыл бұрын
@@bobweiram6321 am planning to buy MacBook Pro 13 m2 chip
@tompov2272 жыл бұрын
I would suggest any apple silicon Mac mini. Extremely powerful for a frankly ridiculously low price. If u want portable get a used 13” M1 or m2 MBP for battery life and fans
@yannick83142 жыл бұрын
@@Daystarjn if you want a MacBook buy m2 air or 14“ pro the 13“ is just a more expensive air with old design. Or you could go for a cheap m1 air.
@Ni7ram2 жыл бұрын
in the swift UI example, it reads "struct LoadingView: view"... isnt that inheritance? great video Sean!
@seanallen2 жыл бұрын
I see where that could be confusing, but in the case of a struct you are conforming to a protocol when you do that. So "LoadingView" is conforming to the "View" protocol.
@Ni7ram2 жыл бұрын
@@seanallen super clear. thanks sean!
@victorriurean2 жыл бұрын
nice
@王登科-u5c Жыл бұрын
I absolutely loved watching Swift - Class vs. Struct Explained by Sean Allen on KZbin! As someone who is starting out in iOS development, this video was incredibly helpful in explaining the differences between classes and structs. The way Sean explained the concept of reference types and value types was easy to understand, and the visuals he used to illustrate his points were very effective. I want to thank Sean for making this video and for sharing his knowledge with the iOS development community. His clear and concise explanations make even the most complex concepts easy to follow. I also appreciate the discount code he provided for Squarespace - I'm definitely going to check it out! Overall, I highly recommend this video to anyone who's interested in iOS development or is preparing for an interview. Sean's expertise and teaching style make this video a must-watch for anyone who wants to improve their understanding of Swift programming. Thank you, Sean!
@chudchadanstud Жыл бұрын
Not sure why my comment was deleted, but I said Structs being light weight doesn't make sense since they are passed by value. There's a lot of coping, creating and destroying of data. That is performance heavy.
@seanallen Жыл бұрын
I didn't delete any comment. And in my comments backend, I see the comment right below this one (would provide a screenshot if I could)
@chudchadanstud Жыл бұрын
@@seanallen I think it was KZbin delaying my comment for some reason. I saw it pop-up.
@chudchadanstud Жыл бұрын
Structs being light weight because they're passed by value doesn't make sense. In many languages reference types are light weight, since only one instance of that thing exists. Creating and Destroying objects has a severe performance cost. Value types are also copied. In your SwiftUI example it looks like Structs also have inheritance. They inherit from View.
@danielcrompton781810 ай бұрын
Nah they don’t inherit from View, they conform to the View protocol
@wlcrutch7 ай бұрын
Yeah…sticking with C…
@tsunningwah347111 ай бұрын
xxxxx😂❤😂😂😂
@asherazeem32822 жыл бұрын
You also can use inheritance in struct. But their inheritance does work only for protocols. So you can't say there is no inheritance in struct. 😉
@noamif2 жыл бұрын
That’s not inheritance, that’s protocol implementation/ compliance