UIViewController - Lifecycle | Swift | viewDidLoad

  Рет қаралды 41,832

Sean Allen

Sean Allen

Күн бұрын

Пікірлер: 87
@rkk9829
@rkk9829 4 жыл бұрын
This video is really great for Jr/beginner devs. A *LOT* of times Jr/beginner devs don't call super when using some kind of base/custom class and then just wonder what went wrong. I can't even count how many times I had to explain this lifecycle to Jr/beginner devs.
@seanallen
@seanallen 4 жыл бұрын
I agree, this topic an cause a lot of problems for those developers just starting out.
@gugaemc
@gugaemc 4 жыл бұрын
Excellent video, Sean. This is the kind of thing every tutorial/course skips (because they're focused on teaching the the app workflow or whatever), but should be basic knowledge for every one.
@seanallen
@seanallen 4 жыл бұрын
Thanks Gus!
@VincentGroenewold
@VincentGroenewold 4 жыл бұрын
Damn nice one! I'm actually quite "far" in Swift now, but this is a thing I always had questions about and forgot to actually find out properly. Thanks! Once again! :)
@seanallen
@seanallen 4 жыл бұрын
Happy to help, Vincent 😀
@khushaljhalani
@khushaljhalani 4 жыл бұрын
finally.. cleared my Lifecycle concepts :p :) ... really very nicely explained. Great Job bro.
@seanallen
@seanallen 4 жыл бұрын
Happy to hear it helped, Khushal 😀
@khushaljhalani
@khushaljhalani 4 жыл бұрын
@@seanallen :)
@DatafoxSoftware
@DatafoxSoftware 4 жыл бұрын
Thanks Sean. The last two are interesting.
@seanallen
@seanallen 4 жыл бұрын
Happy to help!
@kuralaybiehler5638
@kuralaybiehler5638 2 жыл бұрын
Thank you! Your explanation of UIViewController Lifecycle so helpful!
@davidsteppenbeck
@davidsteppenbeck 4 жыл бұрын
Great series, Sean! I think a key point worth mentioning for viewDidLayoutSubviews is that it’s **the** place to do anything geometry dependent.
@seanallen
@seanallen 4 жыл бұрын
Good note, David 👍
@a4advanture755
@a4advanture755 3 жыл бұрын
loveyouu seannnnnnnnnn what a amazing teacher are you!
@karalis445
@karalis445 4 жыл бұрын
Thank you a lot Sean for your work! Even if I'm familiar with most of the topics you cover on your channel I have to say thank you because there are few people out there that explain these things clearly as you do! Keep goin' man!
@seanallen
@seanallen 4 жыл бұрын
Thanks Karalis. I definitely plan to keep going!
@martinhassani7266
@martinhassani7266 3 жыл бұрын
Thank you so much Sean for this incredible video! You are my mentor! :)
@kevinbenavides92
@kevinbenavides92 4 жыл бұрын
Damn good review of the VC lifecycle. Thank you.
@seanallen
@seanallen 4 жыл бұрын
Happy to help, Kevin 😀
@mattkruckeberg9798
@mattkruckeberg9798 4 жыл бұрын
Good stuff man. Jason and I were just talking about this last week.
@seanallen
@seanallen 4 жыл бұрын
Thanks Matt!
@JasonMitchellAZ
@JasonMitchellAZ 4 жыл бұрын
🤩
@Sparroweatshawk
@Sparroweatshawk 3 жыл бұрын
This is great info. That you for making this video. The only thing I see that is missing, is that you did not mention that if your view isn't using fullscreen, then ViewWillAppear and ViewWillDisappear, will not be called when dismissing the view that has been pushed to the top of the view stack. Cheers.
@prachibile2798
@prachibile2798 3 жыл бұрын
I liked this video. I have started learning iOS recently and I was wondering about this one. Nice video :)
@gakkieNL
@gakkieNL 4 жыл бұрын
Great video, nice and short, to the point!
@seanallen
@seanallen 4 жыл бұрын
Thanks Gakkie!
@aviadsabag8193
@aviadsabag8193 4 жыл бұрын
Another awesome video Sean! :)
@fatihsumbul7621
@fatihsumbul7621 4 жыл бұрын
When I see the that subtitle. I have an idea about lifecycle Why I would like to watch. But When I saw the video of the Sean allen. I should watch regardless of the subject.
@seanallen
@seanallen 4 жыл бұрын
I appreciate the support 😀
@RahulPahuja1991
@RahulPahuja1991 4 жыл бұрын
much needed sean thanks alot
@valeriiazakharova4886
@valeriiazakharova4886 4 жыл бұрын
great explanation, thanks
@seanallen
@seanallen 4 жыл бұрын
Glad it was helpful!
@VarunParakh
@VarunParakh 4 жыл бұрын
I was asked loadView vs viewDidLoad loadView gets called automatically to load & attach your view to the VC if the view is nil. viewDidLoad gets called once your view finishes loading.
@pallavi6130
@pallavi6130 4 жыл бұрын
surprised to see that your very helpful video has only 9607 views
@seanallen
@seanallen 4 жыл бұрын
I can't really control the views, but I'm happy to hear you found the video helpful!
@JardaMach
@JardaMach 4 жыл бұрын
Great video, thank you for it! It's fun to refresh what those methods that we use so automatically do in the background. btw: you have a typo on: 6:38 - calling super.viewDidAppear in viewDidDisappear func. Which is also pretty common mistake b/c those funcs are named so simillarly. Cheers!
@seanallen
@seanallen 4 жыл бұрын
Doh... yup, just a simple oversight on that type. Like you said... so common 😀
@VijayParmar-bq2rf
@VijayParmar-bq2rf 4 жыл бұрын
Very Good Explanation of view controllers lifecycle !! I bit confused that why UITableview Delegate and Data source method call 2 or 3 times when it table loads or reload the table.
@seanallen
@seanallen 4 жыл бұрын
Thanks Vijay. Glad you liked it. I'd have to dig into your code to answer the second part of your question. Tough to say without seeing what's going on.
@sravk245
@sravk245 4 жыл бұрын
Excellent video.
@seanallen
@seanallen 4 жыл бұрын
Thanks, Srav
@RahulYadav-im4cl
@RahulYadav-im4cl 4 жыл бұрын
Very Helpful 🙏🏻
@seanallen
@seanallen 4 жыл бұрын
Happy to help!
@demo84demo
@demo84demo 4 жыл бұрын
Great Video! Thanks
@seanallen
@seanallen 4 жыл бұрын
Happy to help, Dave!
@denisg1208
@denisg1208 4 жыл бұрын
Thanks for the video. Does it make sense so put Layout setup in viewWillLayoutSubviews instead of viewDidLoad?
@seanallen
@seanallen 4 жыл бұрын
Not unless you need to do anything custom based on when the views bounds change.
@andrevdw747
@andrevdw747 4 жыл бұрын
Hi Sean, just a off topic question. Till now build app in SB. Is it possible to start new project with SwiftUI and move everything over? Thanks!
@conorhoward10
@conorhoward10 4 жыл бұрын
Hi Sean / community, does anyone have any examples for when it is better to use viewDidDisapper over viewWillDisappear? Some examples I can find (stopping audio, stopping timers, etc.) seem to be suited for either method. It sounds like the example in the video for viewWillDisappear (saving state of a form) is best suited there because if we were to try that in viewDidDisappear the form will be gone so we can no longer reference it's state. My understanding at the moment is that everything will work in viewWillDisappear so viewDidDisappear seems redundant. Any thoughts?
@monicaluo1122
@monicaluo1122 4 жыл бұрын
Thank you! Why did you just say viewDidLoad on the subject - I was worried that you would only talk about that func in this video.
@seanallen
@seanallen 4 жыл бұрын
Because the title would have been way too long if I listed them all 😀. And view did load is the most searched.
@fredericgomes6757
@fredericgomes6757 4 жыл бұрын
Well explained, 👍
@seanallen
@seanallen 4 жыл бұрын
Glad you liked it, Frederic.
@samha1513
@samha1513 2 жыл бұрын
Devmountain worth it ?
@ramzesenok
@ramzesenok 4 жыл бұрын
Great video, Sean! I’m just wondering: you say viewWill/DidAppear() gets called when the view is added to the view hierarchy. But when you go *back* to the search, why does it trigger this method if the view controller is already there in hierarchy, just behind the top one?
@oscara9709
@oscara9709 4 жыл бұрын
Thank you so much :D just I am a bit confused. When you talk about calling super... I remember that a programmer said that in swift you first initialize all the vars from your current class and then you called super, so in this case you have to call super first because first is going to initialize your vars from your current class? the method from the super class? and my second question, when you talk about the navigation controller it didn't load the view did load again but that was the case only because that is the first scene from the stack of view controllers that the navigation has right? because when using segue or navigation and then going back eliminates that view from memory. Thanks for the video!! and sorry for the looong comment.
@MarvelousLXVII
@MarvelousLXVII 4 жыл бұрын
Great tutorial. Please write a book lol.
@Rohitkumar-xy5jg
@Rohitkumar-xy5jg 2 жыл бұрын
Thank you Sean Allen for conceptual video and really that helps me alot. when you override viewDidDisappear function i think in viewDidDisappear function body the method will override super.viewDidDisappear(animated) instead of super.viewDidAppear(animated). Thanks
@multitudes389
@multitudes389 4 жыл бұрын
Love your .systempink hoodie :)
@seanallen
@seanallen 4 жыл бұрын
😂
@Travelicious-Tales
@Travelicious-Tales 5 ай бұрын
Hey! I am a beginner in ios dev and I have a question to ask: What are the methods triggered when the whole app goes to background or gets terminated. I am not asking about life cycle methods but view lifecycle methods. Pls explain in detail or share some material/tutorial link for it if possible 😅
@vamsi3877
@vamsi3877 4 жыл бұрын
loadView() will call before viewDidLoad()
@sami790311
@sami790311 4 жыл бұрын
Just missing Swift News every Monday :/
@seanallen
@seanallen 4 жыл бұрын
Don't give up hope... It may return in some form.
@isaacclark9825
@isaacclark9825 4 жыл бұрын
Are you still living in the midwest? Have you moved to NC yet?
@seanallen
@seanallen 4 жыл бұрын
Not yet. Gonna hang out here for the summer, then move in the fall.
@zaidafzal9208
@zaidafzal9208 4 жыл бұрын
It's very informative video But you please make video on viewdidAppear() , viewWillDissapear (), viewDid Disappear() With real example ?
@mak_whisk
@mak_whisk 3 жыл бұрын
Thank you
@Tenly2009
@Tenly2009 3 жыл бұрын
This video should be MANDATORY and REQUIRED viewing before any developer ever creates their first view. There should also be a similar video for TableViews and CollectionViews. If I had seen this before I began developing for iPhone, it would have saved me a year and a half (literally) of head scratching. Although if you’re the type that believes in “magic”, maybe take a pass on this... 😆
@dev_apostle
@dev_apostle 4 жыл бұрын
You must be a smallville fan cause your animated name resembles the intro to that show. And you are wearing red.
@seanallen
@seanallen 4 жыл бұрын
Never seen an episode, to be honest.
@wowtheworldchannel
@wowtheworldchannel 4 жыл бұрын
👍🏻
@Zeusevo1
@Zeusevo1 3 жыл бұрын
Good one. Thumbs up and Sub buddy
@seanallen
@seanallen 3 жыл бұрын
Thanks for the support, Zuesevo 😀
@tenminutetokyo2643
@tenminutetokyo2643 4 жыл бұрын
Oh yeah dood...
@evgenykarkan6939
@evgenykarkan6939 4 жыл бұрын
noone noticed that he has forgotten to mention loadView and loadViewIfNeeded
@w0mblemania
@w0mblemania 4 жыл бұрын
It's not necessary to bring up discussion of these methods, or many others. For the vast majority of iOS work, loadView and loadView are not used. Apple even tell us to NOT use them when working with IB.
@seanallen
@seanallen 4 жыл бұрын
Well said, w0mbles. I've found that when teaching, often times too much information can be more confusing than helpful. Especially to those early in their learning journey (which is a large portion of my viewers). With my videos, I try to find a balance between giving enough valuable information and not overwhelming the viewer.
@evgenykarkan6939
@evgenykarkan6939 4 жыл бұрын
@@w0mblemania `loadView` is an essential part of VC LC, you may be surprised but still in 2020 many developers prefer making UI in code. It's a place where to set a custom view to viewcontroller's view.
@w0mblemania
@w0mblemania 4 жыл бұрын
@@evgenykarkan6939 I write 100% of my iOS UI in code, and have done so for years. 'loadView' is not an essential part of a primer on the UIViewController lifecycle. Instead of picking on Sean for some perceived shortcoming, how about you make a video about UIKit lifecycles, showing us how it's done?
@evgenykarkan6939
@evgenykarkan6939 4 жыл бұрын
@@w0mblemania Yes, you can ignore overriding `loadView` if you write your UI code inside `viewDidLoad`. But this is a direct way to a Massive View Controller if so. I'm neither a teacher nor a blogger.
@azsok
@azsok 3 жыл бұрын
nicely explained, thank you. but you know what the names given by apple sucks. android lifecycle method names are much much better.
@oliverletterer3854
@oliverletterer3854 4 жыл бұрын
🙅‍♂️
@joseba9973
@joseba9973 3 жыл бұрын
google ads plus this dudes ads... lol
Swift - What to Ask Them? - iOS Interview Questions
13:31
Sean Allen
Рет қаралды 32 М.
Swift - Result Type - Cleaner Network Calls
12:07
Sean Allen
Рет қаралды 20 М.
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 5 МЛН
I was just passing by
00:10
Artem Ivashin
Рет қаралды 18 МЛН
UIViewControllers in iOS and Swift
28:50
Sam Meech-Ward
Рет қаралды 7 М.
How to use Lazy in Swift
9:56
Sean Allen
Рет қаралды 39 М.
Filter, Map, Reduce - Swift - iOS Interview Questions
11:08
Sean Allen
Рет қаралды 54 М.
How to use Model View Controller MVC in iOS (Swift 2020)
16:34
iOS Academy
Рет қаралды 25 М.
Weak and Unowned Self Closure Memory Leak Fixes
12:21
Lets Build That App
Рет қаралды 56 М.
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 5 МЛН