Easy to understand video. I initially searched for Google with key words "Swift class vs struct" in video category and watched the first video done by others in the search results. Your video is better than the first video returned by Google.
Thanks Isaac! I'm almost done with this series. I still have debugging, closures, and networking to cover... But after that, I'm open to suggestions if you've come across any!
Best example out there. I have started learning swift coding 3 days back and it made me wonder what is the difference between these two? SO glad I stumbled across this video.
Sean Allen let me throw out some tutorial ideas for you which I feel have not been covered properly in youtube: what do the app delegate and plist files do in detail, what is the app window set in app delegate and how to use multiple windows (to show global pop ups, for example), how does xcode combine and translate our storyboard file to our code, how to use awakeFromNib and Xib/Nib files. Thanks!
Thanks for this (and all the other videos in this series). They are very helpful. Q: how about methods? Is there a difference in their ability to handle methods? Thanks.
Really great explanation. Thanks. For the struct example you set stoleniPhone to a variable instead of a constant which was the case for the stolenMacBook. Was that on purpose?
I loved the analogy!! I’m still a beginner and in the class I understand everything but the self.year and self.color. Is that necessary? Also what does it mean?
I'm assuming you're talking about the init method. If that's the case, when you initialize an instance of the class (create it), you need to set those properties. So we are setting the properties on that class to the information we pass via the parameters.
I get it, but starting at 2:04 you create two constants and call them variables Then for the struct example at 3:59 you create a constant and a variable Does this effect the class or struct behavior?
As usual, great video! I want to build an app that displays health tips based on the day, time of day, and the user's preferences (e.g. gender, age, diet). I'll use a Firebase Database. Each user will see personalized tips based on their preferences. I'm confused on how to build the data structures? Thanks in advance for your help!
I always thought if I had a struct, and create an object, myobj. If I were to pass it like myfunct(mystruct& myobj) it would be passed by reference. Wouldn't it?
Thanks Valentins, it's an LG 34 inch curved Ultra-Wide. I did a video about my setup here that you might enjoy: ua-cam.com/video/ZiYx_4eeOms/v-deo.html
Great explanation. Does this not work in C++? #include using namespace std; class car { public: int wheels; string colour; car(int x,string y) { wheels=x; colour=y; } }; int main() { car c1(10,"Blue"); car c2=c1; c2.wheels=4; cout
Hi Sean! Thanks for making this explanation. I am just on my way to learning Swift programming and this helped me a lot. But there is still very much to learn for me. It seems a long journey.
Glad it was helpful, Lukas. You are right... it is a LONG journey, so patience is key. Most devs take at least 6-12 months of learning before finding their first job.
Patience and continous practice. Sometimes it is overwhelming for me, still forgeting a lot of new stuff I've learnd. Sometimes I feel so dumb in this area. In Poland, Swift is a niche so I think finding a job here will be difficult, but for some reasons I see the future in this programming language. Anyway, You've got a new subscriber.
Thanks Lukas... check out some of my videos about "how I became an iOS Dev in 7 months"... and other videos in my "Thoughts & Experiences" playlist. You'll find a lot of videos talking about that type of stuff.
Can you explain in detail what a protocol and a delegate are? I liked the example you used in this video about the excel sheet vs. the google doc, it cleared a lot up
I have a dedicated "Delegates and Protocols" video coming up soon, but probably won't go live for a week or two. In the meantime, I describe Delegates and Protocols using a Boss/Intern analogy in my video about UIButtons in TableView Cells here: ua-cam.com/video/UPrBXUWPf6Q/v-deo.html
I know these interview tips are pretty old. But can you do an iOS system design interview? For example, you are tasked to make an app for insurance claim, how would you set up your models, views, and controllers.
Nicely explained. Absolutely love it. I have currently enrolled in Ray Wenderlich Udemy course. The course is good but they have made it difficult for students like me to understand struct using the pizza restaurant analogy. Have you come across any good material that you recommend that can help solidify the struct, classes and computed properties in swift. I am sure I will like your recommendations. Thanks.
I get why you would use a class if you want inheritance, but let's say you don't need inheritance. Do you have examples of why something should be reference type vs value type? A.k.a. with inheritance out of the picture, when should I use Class vs Struct?
If you have myMacbook = Macbook(initialize) and stolenMacbook = Macbook(initialize) and you change a property in either one of the objects, it doesn't affect one another. You can say I'm slightly confused.
Can i use Intger year Flaot colour instead of Var year Var colour ????? Because we haven't used the term var yet (we use for example intger or flaot or char)
Can you give me a clear formula or logic question for this program, and as an example of that question, for example, a man who has an iPhone, an Asu color, and a version 7 that was stolen, I calculate that by using the class ..... I want such a question, but formally and understandably from your presence
Hey Sean, thank you for creating these simple and understandable videos! There are really easy to follow and nice to watch! With reference to this one, there was a question that didn't leave my mind.. It is related to one of your previous videos in which you explain the difference between let and var. My question is, why does the compiler not scream that the stolenMacBook variable is a constant (let) but its property color is modified in the next line..? Thank you in advance and please carry on making these videos!
Is that why you made stoleniPhone as var rather than a let, is because it's a value typed whereas stolenMacbook is a reference type os you defined it as a let??
Watch Next - iOS Take Home Project - Job Interview Practice - Free Preview - ua-cam.com/video/MSIe2y6Fee8/v-deo.html
I just wonder how did it came to your mind such a simple yet best analogy to explain the concept. Its really impressive.Genious
Thanks! I've always been good at coming up with analogies to explain things in a relatable way. Thanks for watching!
Yea good job bro!
I agree, Sean, I've been watching your videos and you do an awesome job with the analogies! You're a natural teacher! 😃
Sulabh Agarwal it’s called common sense ‘genius’
Impressive 2 years later. Point driven home. Not just to the door. To the very heart of home.
Glad it was helpful 😀
Easy to understand video. I initially searched for Google with key words "Swift class vs struct" in video category and watched the first video done by others in the search results. Your video is better than the first video returned by Google.
Thanks Tony! Glad you found it helpful.
Your videos on interview questions are what I like best. More please!
Thanks Isaac! I'm almost done with this series. I still have debugging, closures, and networking to cover... But after that, I'm open to suggestions if you've come across any!
Best example out there. I have started learning swift coding 3 days back and it made me wonder what is the difference between these two? SO glad I stumbled across this video.
Happy to help, Harsh!
Why struct can't inheritance, could you please explain in brief?
Google doc and emailing word doc analogy to references and values ! BANG ON !!!!!
Glad you enjoyed that analogy, Yash!
really made sense. excellent work!!! love it
I was very confused about this subject until I found your video. Thank you for the great analogy and excellent lesson!
Glad it was helpful!
Best analogy for the two, I got tripped on it in a book I bought and other videos. Thanks
Glad it was helpful!
Awesome analogy, understood it from the beginning
Happy to help!
Your teaching skills are godlike - can’t believe i only just came across your channel. Awesome stuff man, keep it up
Thanks! Glad you're enjoying the channel.
Sean Allen let me throw out some tutorial ideas for you which I feel have not been covered properly in youtube: what do the app delegate and plist files do in detail, what is the app window set in app delegate and how to use multiple windows (to show global pop ups, for example), how does xcode combine and translate our storyboard file to our code, how to use awakeFromNib and Xib/Nib files. Thanks!
Struggling with the difference between classes and structs? Leave a question here, I'm happy to help.
Hey Sean, the way you explained is awesome. Just tell me when to use class and when to use struct. Thank you so much.
Thanks Satham! Glad you enjoyed and got value from the video.
Thanks for this (and all the other videos in this series). They are very helpful.
Q: how about methods? Is there a difference in their ability to handle methods? Thanks.
the excel vs google sheets analogy is excellent!!! it makes me understand the topic instantly, unlike some other tutorials.
Happy to help!
Simple and to the point. Exactly what I needed
Glad you enjoyed it, Thomas!
your the best teacher i ever had in ios teaching... hats off
keep going
Your the best
Thanks Shehin!
dear lord, this was the best explanation I have found even better than what my instructor could come up with!
Glad it helped!
No one could have explained this concept better. To the point, great video!
Thanks for the kind words 😀
Although already said but once again i will say, your analogy is perfect here. It just got settled in my mind.
Glad you're enjoying the videos!
Thanks!. Can you explain when to use class and when to use struct?
Clear to the point, finally i can fully understand the difference. thank you very much, you're doing great job and inspiring us. keep up the good job.
Thanks Ezuu! Glad you finally understand the difference!
These videos are worth gold for me u explain so good
Thanks for the kind words, Sebbe. Happy to hear you find it helpful 😀
simple yet great explanation!
Thanks for the simplest and amazing explanation. I have 1 doubt, why are you using 'Let' for stolenMacBook but 'Var' for stoleniPhone ?
I've just recently stumbled upon your channel and is terrific! Thank you very much, now you're my way to go when I want to learn a Swift Concept.
Happy to hear that, Daniel. I've been taking a little break from new videos, but will be back in early September. See ya then!
Really great explanation. Thanks. For the struct example you set stoleniPhone to a variable instead of a constant which was the case for the stolenMacBook. Was that on purpose?
Thanks man. Your content is effective. Much better than most paid coursera courses. Keep up the good work
Thanks Vishwas!
Awesome. One of the best explanations between classes and structs that I have came across. Thanks Sean.
Happy to hear it helped, Nilesh!
Best video on classes and structs i came across.....
Efficietly clears the actual concept
Thanks Asma! Glad you enjoyed it.
I loved the analogy!! I’m still a beginner and in the class I understand everything but the self.year and self.color. Is that necessary? Also what does it mean?
I'm assuming you're talking about the init method. If that's the case, when you initialize an instance of the class (create it), you need to set those properties. So we are setting the properties on that class to the information we pass via the parameters.
This is an amazing explanation. Thank you!
Very nicely explained. I'm thinking about learning Swift. I'll be checking out your content more in the future, hopefully. Cheers!
this logic is fuc*** cool , magnificent i would never forget it from now
haha, thanks. Happy to hear it was helpful 👍
That was so easy to understand. Thanks
Maybe you could explain the self. in another video
Glad it was helpful! I've added the self keyword to my video to-d list.
I get it, but starting at 2:04 you create two constants and call them variables
Then for the struct example at 3:59 you create a constant and a variable
Does this effect the class or struct behavior?
Thanks for the brilliant example.. can you do one for Closure? mainly about why to use them and where to use them. *Trailing + autoclosures too .
I plan on redoing this series sometime in 2019 (as you can see these are starting to get old). At that time, I'll include closures.
Really well structured tutorials with fast explanations and info...tnx for this man, really helps a lot !
Glad you enjoyed it, EmiN!
Very different analogy. Wonderful and useful video.
Glad you enjoyed it, A P. Glad to hear it helped.
I think almost every video of yours have my comment of thanks. And again, thanks sean for the simple and best analogy. 😄👍
You earned yourself a damn subscription for this video. Thank you for the great content!
Perfect! Very well explained, Sean. Really loving the short video tutorials :-) keep it up!
+Dennis van Mazijk glad you enjoy it Dennis!
Great video! Thanks for this. I understand and remember now :)
Why did you use var for the struct and let for the class?
Thank you very much! This is so clear!
Great work Sean! Enjoying your videos. Love the way you explain things. Thanks
+Ivan Pena thanks Ivan! Glad you're enjoying them. More on the way!
Your channel is a goldmine, keep up the great work !
Thanks for the kind words!
Thanks very much. Very clear now on use cases for Structs.
Glad you found it useful, Martin!
When u started swift, how long did it take u to become good?
Another point worth mentioning is that structs are read-only by default. Lost points in an interview because I didn’t know that
Isn't value types live in stack and reference in heap ? value types working more faster then reference types ?
When we should use class and strut?
Great channel Sean, congratulations for your work. I wish the best for you !!
Thanks Lucas, I'm happy you're enjoying the videos. Hopefully they are helping!
Amazing explanation. Finally I get it.
Glad it helped, Mark!
As usual, great video! I want to build an app that displays health tips based on the day, time of day, and the user's preferences (e.g. gender, age, diet). I'll use a Firebase Database. Each user will see personalized tips based on their preferences. I'm confused on how to build the data structures? Thanks in advance for your help!
What is the difference between mutating and overriding a function
I always thought if I had a struct, and create an object, myobj. If I were to pass it like myfunct(mystruct& myobj) it would be passed by reference. Wouldn't it?
Thanks a lot, dude! This is such an excellent example.
Thanks for the explanation !
nice Analogy !
can we create instance optional object in a class like var name:String?
Great analogy, nice clarification! Thank you...
I like this guy. He has wide & great knowledge. Thanks for good vid !
Happy to help!
Great videos. Keep going!! what monitor a u using? (The big one near your laptop ) Thank You!
Thanks Valentins, it's an LG 34 inch curved Ultra-Wide. I did a video about my setup here that you might enjoy: ua-cam.com/video/ZiYx_4eeOms/v-deo.html
Thanks man.
Great explanation. Does this not work in C++?
#include
using namespace std;
class car
{
public:
int wheels;
string colour;
car(int x,string y)
{
wheels=x;
colour=y;
}
};
int main()
{
car c1(10,"Blue");
car c2=c1;
c2.wheels=4;
cout
Hi Sean! Thanks for making this explanation. I am just on my way to learning Swift programming and this helped me a lot. But there is still very much to learn for me. It seems a long journey.
Glad it was helpful, Lukas. You are right... it is a LONG journey, so patience is key. Most devs take at least 6-12 months of learning before finding their first job.
Patience and continous practice. Sometimes it is overwhelming for me, still forgeting a lot of new stuff I've learnd. Sometimes I feel so dumb in this area. In Poland, Swift is a niche so I think finding a job here will be difficult, but for some reasons I see the future in this programming language. Anyway, You've got a new subscriber.
Thanks Lukas... check out some of my videos about "how I became an iOS Dev in 7 months"... and other videos in my "Thoughts & Experiences" playlist. You'll find a lot of videos talking about that type of stuff.
Great description
This is the best tutorial, thanks😍
Thanks Rahaf! Happy to hear it helped.
Hi what about enum? Is that a reference type or a value type? Does it take advantage of inheritance? Thank you.
Thanks for the magnific explanation!
No problem, Juan! Glad you enjoyed it!
randomly played this video, I am coming from c++ and use out of curiosity, how do you copy a class in swift ?
love this channel, you helped me out so much
Glad it's helping, Hamann. Feel free to reach out with any questions.
Can you explain in detail what a protocol and a delegate are? I liked the example you used in this video about the excel sheet vs. the google doc, it cleared a lot up
I have a dedicated "Delegates and Protocols" video coming up soon, but probably won't go live for a week or two. In the meantime, I describe Delegates and Protocols using a Boss/Intern analogy in my video about UIButtons in TableView Cells here: ua-cam.com/video/UPrBXUWPf6Q/v-deo.html
Oh ok perfect, thank you
in line 30, `var stolen ...` but class example uses `let stolen ...`, is there a difference btw those keywords in regards to class vs struct?
I know these interview tips are pretty old. But can you do an iOS system design interview? For example, you are tasked to make an app for insurance claim, how would you set up your models, views, and controllers.
Very useful: This is perfectly clear!
Nicely explained. Absolutely love it. I have currently enrolled in Ray Wenderlich Udemy course. The course is good but they have made it difficult for students like me to understand struct using the pizza restaurant analogy. Have you come across any good material that you recommend that can help solidify the struct, classes and computed properties in swift. I am sure I will like your recommendations. Thanks.
Try Paul Hudsons books here: gumroad.com/a/762098803
@@seanallen Thank you Sir. Really appreciate it.
I get why you would use a class if you want inheritance, but let's say you don't need inheritance. Do you have examples of why something should be reference type vs value type? A.k.a. with inheritance out of the picture, when should I use Class vs Struct?
If you don't need inheritance, and there's no need or reason to keep a reference to the object, then I would use a Struct.
I'm confused. Are you in essence making an object of the object?
If you have myMacbook = Macbook(initialize) and stolenMacbook = Macbook(initialize) and you change a property in either one of the objects, it doesn't affect one another. You can say I'm slightly confused.
Where would one use this code in a practical sense?
Example looks good.. keep posting thank you
Glad you enjoyed it Prasad!
Sean does this mean that myClassButton is the subclass? so it inherits the definitions from UIButton?
That is correct.
Can i use
Intger year
Flaot colour
instead of
Var year
Var colour
?????
Because we haven't used the term var yet (we use for example intger or flaot or char)
Great explanation!!👍🏿
Great analogy Sean.
Glad you liked it 😀
Thanks, that was a very well explained point.
Glad you liked it!
Hello Sean. Please help me. Nested or not nested structures? which practice is better?
They are fine. As always... it depends on the situation and how they are used.
@@seanallen, thanks for the answer!
Stolan and myMac are both constants, how come we can change its properties?😢
Can you give me a clear formula or logic question for this program, and as an example of that question, for example, a man who has an iPhone, an Asu color, and a version 7 that was stolen, I calculate that by using the class ..... I want such a question, but formally and understandably from your presence
Hey Sean, thank you for creating these simple and understandable videos! There are really easy to follow and nice to watch! With reference to this one, there was a question that didn't leave my mind.. It is related to one of your previous videos in which you explain the difference between let and var. My question is, why does the compiler not scream that the stolenMacBook variable is a constant (let) but its property color is modified in the next line..? Thank you in advance and please carry on making these videos!
Excellent explanation! Thank you!
Happy to help!
Is that why you made stoleniPhone as var rather than a let, is because it's a value typed whereas stolenMacbook is a reference type os you defined it as a let??
Great video.thanks a lot sean
Glad you liked it, Vinayak.
Class - ByRef and Struc - ByVal.... yes!!!! :)
This helped so much, thank you!
Glad it helped!
Great, clear explanation.
Thanks Jason!
I love you haha such a basic concept but confused me so hard
Happy to hear it helped 👍
excellent but can we slow down because it feels like your going a million miles an hour to get it in 7:34
Hey Matthew, this was one of my earlier videos. I've improved my pacing a lot since then.
do u have a Flight to catch?
Not anymore.
@@seanallen so be little slow while you speak.. that makes us easy to grasp! Thanks
I've worked a lot on that. This video series is from when I first started my UA-cam channel. My recent videos are a lot better.
Good Explanation, Thank You.
Happy to help, Anil!
Make a videos on enums.
Thanks in advance..
It's on the to-do list. SO many videos, so little time...
Sean Allen Thanks for responding sir...
Nice tutorial sir
Thanks Mantu!
Great explanation! thanks
Happy to help, Nir!
hello, sean I love your tutorial thanks for help!
Happy to help!