Your course is excellent, beats all others I've seen hands down! Your course/videos clearly show how to use the different items with thoughtful examples and explanations. This video explains what I found to be the most confusing, when to use @StateObject and @ObservableBbject. Looking forward to the Environment video. Thank you for taking the time and effort to create this course, it sets the gold standard!
Thanks Daragh! I really appreciate that. Yes, the @EnvironmentObject is next... if you understood this video, the next one should be a breeze. Thanks for watching :)
I am SO happy I found your channel. Amazing quality. Great clear communication, sympathy for newbies, explaining everything, quality mic, everything. Thanks for all your hard work!
Nick. I am a CTO who was trying to learn Swift for fun. I had visited a lot of material and I find your approach to be the best. Beats even the paid materials by a long distance. My best wishes and do let me know how we can help contribute to you besides referring. You should be hitting at least 100K viewers.
I have been watching your videos for a few days now. I also watch some others content creators as well. Out of all the ones I watch I find yours to be excellent and unique. You are the first person to actually make videos explaining each thing in great detail. All the others just build apps that get followed with maybe some explaining. Thats great too but this is helping me learn so much better.... So Thank You for making all of these and I hope you never stop!
Perfect, perfect, perfect! Every day I learn from your videos. You were not the first in my path, but by far the best. I have never understood complex topics so easily, as I began to understand with you. Clear beautiful speech allows me to understand you (English is not my native language). I'm very happy that I found you. I feel that one mug of coffee will not be enough)) The material costs a whole mountain of mugs of coffee
You're the best, dude! I've been doing this Hacking with Swift course, but I was so confused with the fundamentals, and you are explaining it so simply! I'm very grateful. Thanks.
I started with the Hacking with Swift course too, but when I read the challenge on Day 35 I wasn't confident enough to try complete them, so I started to look for another course & found this one. He explains things so well!
Best explanation of these property wrappers. I’ve spent months trying to grasp managing state and it has been so confusing. This tutorial wasn’t so overly complicated like so I actually grasped the concepts. This entire channel is GOLD!
I have watched over 10 different tutorials on youtube around this concept, you have explained this concept much much much better and cleaner and underestandable than any other tutorial. Thanks a lot!
Thank you Nick. Your videos are still being watched. Very very clear and thoughtful explanation of everything. Ofc it has to be watched maybe twice in order to absorb everything properly but such a video i can watch even 4 times! Keep up the good work!
I started working on SwiftUI and I got stuck at @State and @StateObject, I found your video on the @StateObject, I found this very helpful and now I am planning to learn SwiftUI from your playlist instead of other platforms. Thanks for creating excellent content.
You do such an absolute great job explaining the code. I will now have to give you the title, SMSMI (supreme master swift mentor and instructor). Thanks for a world class video. Bob
Once again I must thank you for this video. It explains things so well where as other videos, that got me started, excluded key points and ended up in a mess when I attempted to create the project I have been tasked with. I am just about to embark on updating my app and feel confident that this has got me over the rather confused situation I had ended up in. I almost feel guilty for getting all your tutorage for free and hope you are generating some revenue from this marvellous series. Thank you once again!
Another great video, Nick! This is probably the most crucial one to date in the Bootcamp series, IMHO. I have a feeling I'll be coming back to it again several times. I've watched a lot of the WWDC videos, but they still left me a bit confused on what the difference was between @StateObject and @ObservedObject and when to use one over the other. In fact, I think I had them backwards in my head, but this video has helped them click into place.
I'm very happy to help this. This was confusing for me as well when I was learning. Once you understand it, it's actually pretty easy to implement. It's definitely important though because we will use these for all of our ViewModels in MVVM architecture!
Im in the same boat. I've been watching videos on @StateObject and @ObservedObject from other creators and they left me extremely confused. Though, after watching Nick's videos on @StateObject and @ObservedObject once, its a bit clearer. Ill still have to come back and watch it a few times. Other topics, he cleared up in 1 shot for me. Nick has my favorite creator for swiftUI. I wish I watched these videos before tackling DogGram though. But once I'm done here, ill redo it.
Can't thank you enough for demystifying the difference between @State & @StateObject , @ObservableObject & @ObservedObject and when to use each one respectively. Thanks bro! Also thanks for introducing me to the ProgressView() 😎
This video explains a lot about the @ObservableObject and @StateObject. I literally learned what those are and how they are used. Thanks a lot for this video. :)
Additional notes for Swift beginners: * At 14:08. If the code is too long, you can remove ': FruitViewModel' from the var declaration, because type of the var is always FruitViewModel.
@@SwiftfulThinking Nick your course is super. But if you have time can you make another video about Picker. It is not working, especially label. And by the way how to make picker with optional value. I think about such pickier but I don't know how to make it In such nice and user friendly look like you do. Thanks for all. The best iOS course on internet is yours. You are legend.
Hey Nick, thanks for another amazing video. I said that many times but will say here again; I watched bunch of tutorials about @ObservableObject, @ObservedObject and @StateObject but this is the first time I understood the logic. Your teaching method is just awesome.
Nick i've finished both swift and swiftui bootcamp, came back to this vid to grasp a little bit more on this, thank you for your good work, please let us know if you have a site to "Buy you a coffee" or somehow retribute some of the knowledge you've given to us.
During this video, I expected you to move the FruitViewModel class to its own file, but you didn't. Are you just delaying the "separate files" concept until a later video? A separate file seems like the logical organization for the code.
Yes, the ViewMode would normally have its own file. I just don’t always create separate files in the videos because it’s easier to organize / display in the tutorial. Moving that code to another file wouldn’t change the actual implementation though!
Quick question Nick... Why have both a FruitModel struct, and a FruitViewModel class? Why not just have a FruitModel class? Sorry, if it's a dumb question! Thank you
@State = @StateObject : @Binding = @ObservedObject. Major difference is @StateObject & @ObservedObject are for instances of your class whereas @State & @Binding are more for your variables. Also, after doing some tinkering with the code I found that having a property with @ObservedObject will not reinitialize the object every time you step away and return to the screen as Nick had said, maybe it happens when you deal with more screens, not sure
Your tutorials are amazing, but I’ve noticed you have some problems with naming. According to the Apple guidelines you’d better use var fruits: [Fruit] = [] instead of var fruitArray: [FruitModel] = [] Words ‘array’ and ‘model’ are redundant.
Nick, we all need your help about initialization of StateObjects. Please, can you explain about initialization of it? When my view getting parameters on init, which I need to initialize StateObject? What i have to do? I heard somewhere, that initialization of StateObject in init of view - is not good idea. But it's very often case. I'm looking information about it, but nothing ...
Yo!! Yes! That's the magic behind all of this. We are using the same ViewModel for all of the views. So if you update it in one place, it will automatically update everywhere. Because the data is @Published, it "published" the change to all of the views that are observing it!
Hey Nick, thank you for the amazing video - it is very handy. I have maybe a dumb question. If you refactor the entire List into a separate struct and then use the reference to this struct in your home view. Where should @StateObject be? In the home view, right?
So in essence, when you write, _"var fruitViewModel: FruitViewModel = FruitViewMode()l,"_ you're instantiating an object of the "FruitViewModel" class. Is that correct?
Yes, when you add the () at the end of FruitViewModel(), you are calling the init() function within the FruitViewModel class to initialize a new object!
Thanks again for an excellent video. You did (as always) and excellent job explaining classes. I do have a question though, in SwiftUI what is the difference between structures and classes; they look pretty similar at first glance (I don't know if classes can also be used to create views but other than that one may think they can be used interchangeably).
@@SwiftfulThinking Thanks for your response. I had a quick glance at the video and realize that it is too advanced for me so I'll be patience and wait until I get there.
@@jalapisco haha for right now, just know that in SwiftUI, all of your Views must be structs and your ViewModels (or any ObservableObject) must be a class. Your data models can be either, but usually are structs.
Is it common and good practice in iOS Dev to pass viewModels around like that? Shouldn't RandomScreen (and each screen) basically have it's own ViewModel? And both ViewModels would access data from a common data storage which would be located lower in the general app architecture?
I think your title might be wrong. Should it not be "How to use ObservableObject and @StateObject in SwiftUI | Bootcamp" wihtout the @, because ObservableObject is the protocol.
Your course is excellent, beats all others I've seen hands down! Your course/videos clearly show how to use the different items with thoughtful examples and explanations. This video explains what I found to be the most confusing, when to use @StateObject and @ObservableBbject. Looking forward to the Environment video. Thank you for taking the time and effort to create this course, it sets the gold standard!
Thanks Daragh! I really appreciate that. Yes, the @EnvironmentObject is next... if you understood this video, the next one should be a breeze. Thanks for watching :)
I am SO happy I found your channel. Amazing quality. Great clear communication, sympathy for newbies, explaining everything, quality mic, everything. Thanks for all your hard work!
So do I
Nick. I am a CTO who was trying to learn Swift for fun. I had visited a lot of material and I find your approach to be the best. Beats even the paid materials by a long distance.
My best wishes and do let me know how we can help contribute to you besides referring.
You should be hitting at least 100K viewers.
I have been watching your videos for a few days now. I also watch some others content creators as well. Out of all the ones I watch I find yours to be excellent and unique. You are the first person to actually make videos explaining each thing in great detail. All the others just build apps that get followed with maybe some explaining. Thats great too but this is helping me learn so much better.... So Thank You for making all of these and I hope you never stop!
Wow! Thanks for the comment Scott. That's really appreciated. I'm very happy to help. Let me know if you have any questions!
Perfect, perfect, perfect!
Every day I learn from your videos. You were not the first in my path, but by far the best. I have never understood complex topics so easily, as I began to understand with you. Clear beautiful speech allows me to understand you (English is not my native language). I'm very happy that I found you. I feel that one mug of coffee will not be enough)) The material costs a whole mountain of mugs of coffee
You're the best, dude! I've been doing this Hacking with Swift course, but I was so confused with the fundamentals, and you are explaining it so simply! I'm very grateful. Thanks.
I started with the Hacking with Swift course too, but when I read the challenge on Day 35 I wasn't confident enough to try complete them, so I started to look for another course & found this one. He explains things so well!
Best explanation of these property wrappers. I’ve spent months trying to grasp managing state and it has been so confusing. This tutorial wasn’t so overly complicated like so I actually grasped the concepts. This entire channel is GOLD!
Man really solved my doubt about @StateObject and @ObservedObject. Please make sure videos like these. It’s amazing
Finally i got clear concept of why, when and where we can use Identifiable, ObservaleObject, @StateObject, @ObservedObject. Thank you Nick
I have watched over 10 different tutorials on youtube around this concept, you have explained this concept much much much better and cleaner and underestandable than any other tutorial. Thanks a lot!
Thank you Nick. Your videos are still being watched. Very very clear and thoughtful explanation of everything. Ofc it has to be watched maybe twice in order to absorb everything properly but such a video i can watch even 4 times! Keep up the good work!
I love the way you explained the diff between @state and observable object. So abundantly clear
I started working on SwiftUI and I got stuck at @State and @StateObject, I found your video on the @StateObject, I found this very helpful and now I am planning to learn SwiftUI from your playlist instead of other platforms. Thanks for creating excellent content.
You do such an absolute great job explaining the code. I will now have to give you the title, SMSMI (supreme master swift mentor and instructor). Thanks for a world class video. Bob
Haha that's a new one 😂 Glad you're enjoying the Bootcamp!
What a great video. Perfect pacing, perfect explanations, and I like how you reinforce important concepts. Thanks again.
your boot camp is incredible awesome!!!
Once again I must thank you for this video. It explains things so well where as other videos, that got me started, excluded key points and ended up in a mess when I attempted to create the project I have been tasked with.
I am just about to embark on updating my app and feel confident that this has got me over the rather confused situation I had ended up in. I almost feel guilty for getting all your tutorage for free and hope you are generating some revenue from this marvellous series.
Thank you once again!
Thanks Pazuzu!
First video I watched from you. Great explanation, easy to understand. Now I have to watch your other videos too :)
Welcome to the channel Tamas! I hope you like them :)
Proud coffee member on a monthly basis now🥳. Please do not stop teaching!
Thanks! More vids coming soon 👍
Not only describe the concept in a straightforward way but also tells the use cases of real projects. GOD bless on you.
Thank you Nick. You explained how to use @StateObject and @ObservedObject perfectly.
Another great video, Nick! This is probably the most crucial one to date in the Bootcamp series, IMHO. I have a feeling I'll be coming back to it again several times. I've watched a lot of the WWDC videos, but they still left me a bit confused on what the difference was between @StateObject and @ObservedObject and when to use one over the other. In fact, I think I had them backwards in my head, but this video has helped them click into place.
I'm very happy to help this. This was confusing for me as well when I was learning. Once you understand it, it's actually pretty easy to implement. It's definitely important though because we will use these for all of our ViewModels in MVVM architecture!
Im in the same boat. I've been watching videos on @StateObject and @ObservedObject from other creators and they left me extremely confused. Though, after watching Nick's videos on @StateObject and @ObservedObject once, its a bit clearer. Ill still have to come back and watch it a few times. Other topics, he cleared up in 1 shot for me. Nick has my favorite creator for swiftUI. I wish I watched these videos before tackling DogGram though. But once I'm done here, ill redo it.
Thank you so much! I finally got it. Amazing video)
You're welcome Sergei!
This was very well explained! Thank you Nick!
Brilliant - you just cleared up for me, why my app reloaded data at times, when I did not want it. And what to do about it. Many thanks.
Can't thank you enough for demystifying the difference between @State & @StateObject , @ObservableObject & @ObservedObject and when to use each one respectively. Thanks bro! Also thanks for introducing me to the ProgressView() 😎
You’re on #50 already? Beast mode 🚀🚀🚀
Dude these tutorials are amazing! Keep up the good work!
Great explanation!
Thank you👍👍👍👍
Great video. Thanks Nick.
Brilliant video! Wonderfully clear and perfectly explained👍👍👍
Omg, you gave me the missing piece I was looking for! Thank you so much! Great content!
Thanks!
This video explains a lot about the @ObservableObject and @StateObject. I literally learned what those are and how they are used. Thanks a lot for this video. :)
please don't stop you make life easier and more simple ♥
Watching a ton of your videos - thank you!
Thanks for watching!
thank you it's by far the best explanation i found for this subject!
Thanks from the bottom of my Heart Mate ❤💚
Wonderful explanation!!! Thank you so much for investing your time making this videos.
🙃
Wonderful for understanding state, stateobj and observable object. Thanks a bunch
keep doing what you doing man
Your explanation techniques is unique and simple..I love it. 👍
Excellent video. Wonderful explanation. I knew most of this stuff but I learned many small details.
Dud you're amazing! Thanks a lot!
Great vid as always. Keep it up! Loving this content and leaving comments to make your YT algorithm better!
Thank you Tomek! That’s very much appreciated 🥳
This video saved my life. Thank you.
Additional notes for Swift beginners:
* At 14:08. If the code is too long, you can remove ': FruitViewModel' from the var declaration, because type of the var is always FruitViewModel.
Do not do this. This will worsen the readability of the code.
The type is inferred from the assignment. Saying it will worsen the readability is your opinion. @@redax3866
All courses are amazing. You are the best.
Thank you for watching :)))
@@SwiftfulThinking Nick your course is super. But if you have time can you make another video about Picker. It is not working, especially label. And by the way how to make picker with optional value. I think about such pickier but I don't know how to make it In such nice and user friendly look like you do. Thanks for all. The best iOS course on internet is yours. You are legend.
Hey Nick, thanks for another amazing video. I said that many times but will say here again; I watched bunch of tutorials about @ObservableObject, @ObservedObject and @StateObject but this is the first time I understood the logic. Your teaching method is just awesome.
Thanks for the comment Ben! Hearing that makes this all worth it for me. I'm glad this video helped 🥳
Top quality course 😍
Amazing explanation! Love all your videos. I was a little confused before and this kinda cleared everything up.
What a well done video ! Kudos to you !
Another excellent video. Thanks very much. It’s very well explained.
Thanks for watching John!
Thank you! You are our lifesaver❤
Great explanation. Thank you so much!
Great explanation, thanks
sir congratulations you have the best course covering swiftui
Wow, haha. I don't know if it's the best, but I'm very glad you're liking it! 🙃
Excellent lessons !
Thanks! 😃
Very well explained !!
Great course! :)
There are so many great ideas in this video
thnk you
I discovered you a few ago . I think that your videos is useful very .Thanks.
Thanks for watching rclk!
Sooo good explanation thanks mate🎉👍
Nick i've finished both swift and swiftui bootcamp, came back to this vid to grasp a little bit more on this, thank you for your good work, please let us know if you have a site to "Buy you a coffee" or somehow retribute some of the knowledge you've given to us.
I’m glad these videos helped! I do have a BuyMeACoffee: www.buymeacoffee.com/nicksarno
Thanks 🍻
Thanks a lot very clear with an exhaustif example
Glad it was helpful!
great tutorial, keep up the good work
Great Video. Thank you !!!
Oh man you are a great teacher
love from Pakistan
Thank U! I am new on programming
The Best! Thanks!
Great, your teaching method is very understandable and helps me a lot, thanks a lot
Really well explained :)
Thank you so much for great explanations
😁😁
Awesome! 👏
thanks man, fantastic video
Thanks for watching Mohamed! 🤙
very well explained!
We ❤️ to hang with u here! 🥳
Nick, thank you so much for your lessons, do you have core data lessons? i did't find it
Yes, they are in the Continued Learning playlist. You can also search “core” across all videos here: www.swiftful-thinking.com/search
During this video, I expected you to move the FruitViewModel class to its own file, but you didn't. Are you just delaying the "separate files" concept until a later video? A separate file seems like the logical organization for the code.
Yes, the ViewMode would normally have its own file. I just don’t always create separate files in the videos because it’s easier to organize / display in the tutorial. Moving that code to another file wouldn’t change the actual implementation though!
Very Good!!!
Quick question Nick...
Why have both a FruitModel struct, and a FruitViewModel class?
Why not just have a FruitModel class?
Sorry, if it's a dumb question!
Thank you
@State = @StateObject : @Binding = @ObservedObject. Major difference is @StateObject & @ObservedObject are for instances of your class whereas @State & @Binding are more for your variables. Also, after doing some tinkering with the code I found that having a property with @ObservedObject will not reinitialize the object every time you step away and return to the screen as Nick had said, maybe it happens when you deal with more screens, not sure
quick question. If I wanted to ensure that the data persists when that application is closed , would I need to save the information in coreData?
Would it be possible to say something more about the "@Environment(\.presentationMode) var presentationMode" line? It is kind of a black box to me.
I will add a video on the @Environment to this playlist in the next few weeks. Thanks for the idea!
underrated
OMG thx so much.I have been struggling about how the fuck updating data works
😂🤣😂
Your tutorials are amazing, but I’ve noticed you have some problems with naming. According to the Apple guidelines you’d better use
var fruits: [Fruit] = []
instead of
var fruitArray: [FruitModel] = []
Words ‘array’ and ‘model’ are redundant.
Good point.. I only do this so that it’s easier to understand for new learners
My brain is burning lmao thanks for videos bro btw
Nick, we all need your help about initialization of StateObjects. Please, can you explain about initialization of it? When my view getting parameters on init, which I need to initialize StateObject? What i have to do? I heard somewhere, that initialization of StateObject in init of view - is not good idea. But it's very often case. I'm looking information about it, but nothing ...
Pleeeease (
Yo! So is it possible for the SecondView to update the information regarding the fruits (eg. changing the fruit count) in the first view?
Yo!! Yes! That's the magic behind all of this. We are using the same ViewModel for all of the views. So if you update it in one place, it will automatically update everywhere. Because the data is @Published, it "published" the change to all of the views that are observing it!
this is beyond me, I'll have to start all over, or get 'boot' out. haha... I started back at Bootcamp #1 🤣
thank you very much
Super! thx man
You're always welcome 🥳
Hey Nick, thank you for the amazing video - it is very handy. I have maybe a dumb question. If you refactor the entire List into a separate struct and then use the reference to this struct in your home view. Where should @StateObject be? In the home view, right?
So in essence, when you write, _"var fruitViewModel: FruitViewModel = FruitViewMode()l,"_ you're instantiating an object of the "FruitViewModel" class. Is that correct?
Yes, when you add the () at the end of FruitViewModel(), you are calling the init() function within the FruitViewModel class to initialize a new object!
Thanks again for an excellent video. You did (as always) and excellent job explaining classes. I do have a question though, in SwiftUI what is the difference between structures and classes; they look pretty similar at first glance (I don't know if classes can also be used to create views but other than that one may think they can be used interchangeably).
Hey! This is not a beginner topic, but everything you need to know about structs vs classes is here: ua-cam.com/video/-JLenSTKEcA/v-deo.html
@@SwiftfulThinking Thanks for your response. I had a quick glance at the video and realize that it is too advanced for me so I'll be patience and wait until I get there.
@@jalapisco haha for right now, just know that in SwiftUI, all of your Views must be structs and your ViewModels (or any ObservableObject) must be a class. Your data models can be either, but usually are structs.
Is it common and good practice in iOS Dev to pass viewModels around like that? Shouldn't RandomScreen (and each screen) basically have it's own ViewModel? And both ViewModels would access data from a common data storage which would be located lower in the general app architecture?
you are the best
can you make a video on firebase or Vapor
Thank you your video. How to use button delete instead onDelete() for List ?
good stuff
I think your title might be wrong. Should it not be "How to use ObservableObject and @StateObject in SwiftUI | Bootcamp" wihtout the @, because ObservableObject is the protocol.