Static properties and methods – Swift for Complete Beginners

preview_player
Показать описание
Other videos in the Structs section:

6. Static properties and methods: This video

Рекомендации по теме
Комментарии
Автор

His didactic is just impeccable! I've never seen anyone explaining complex things so easy and full of examples like he does! Thank you so much for all of this content!! It's hard to believe it's free.

caioliv
Автор

I made a small mistake in the audio – sorry about that! At 0:17 I meant to say "other instances of the same struct" rather than "other structs of the same instance" 🤦‍♂️

twostraws
Автор

You are the Morgan freeman of code. So soothing and precise.
This topic was great have been using static properties for dummy data but never really understood why. 👍🏼

bgriffin
Автор

Wouldn’t it be better to create AppData as an enum so that it cannot be accidentally instantiated?

samsHandle
Автор

Paul I'm loving your entire series, but I have to strongly disagree with your choice of an example here (the School one) for static. School barely fits as an example, but if you HAD to use it, you could have a static called totalStudentsEverywhere or something, and in the add method you could add increment the non-static studentCount and then also the totalStudentsEverywhere value as well. You could show us you creating three different schools, adding two people to the first school, adding 1 to the second school, and adding four to the third school, then call each school's printCount() method, and then call a static printTotalCountEverywhere() method. You'd have to warn people that this isn't a great example because what if you ended up having schools created by some copy or something, and there was no good way to reset the totalStudentsEverywhere value without some reset etc.. but it would get across the idea that those values are global - all School objects share that value. I worry for anyone looking at the example you have in that first half. Sorry that my first comment has to be a criticism.. Keep up the good work!

jlkeegan
Автор

not to be rude: the reason for use of 'static' may make perfect sense but your explanations does not... sorry.

dugrut